next.js 由于依赖项内的冲突而导致生成错误

1bqhqjot  于 2022-11-05  发布在  其他
关注(0)|答案(1)|浏览(161)

如何修复此生成错误:

Failed to compile

./node_modules/material-ui-search-bar/lib/components/SearchBar/SearchBar.js
Module not found: Can't resolve '@material-ui/core/IconButton' in 
'D:\Projects\nextjs\resto\node_modules\material-ui-search-bar\lib\components\SearchBar'

Import trace for requested module:
./node_modules/material-ui-search-bar/lib/components/SearchBar/SearchBar.js
./node_modules/material-ui-search-bar/lib/components/SearchBar/index.js
./node_modules/material-ui-search-bar/lib/index.js
./components/admin/ProductDatatable.jsx
./components/admin/ProductList.jsx

./node_modules/material-ui-search-bar/lib/components/SearchBar/SearchBar.js
Module not found: Can't resolve '@material-ui/core/Input' in 
'D:\Projects\nextjs\resto\node_modules\material-ui-search-bar\lib\components\SearchBar'

Import trace for requested module:
./node_modules/material-ui-search-bar/lib/components/SearchBar/SearchBar.js
./node_modules/material-ui-search-bar/lib/components/SearchBar/index.js
./node_modules/material-ui-search-bar/lib/index.js
./components/admin/ProductDatatable.jsx
./components/admin/ProductList.jsx

./node_modules/material-ui-search-bar/lib/components/SearchBar/SearchBar.js
Module not found: Can't resolve '@material-ui/core/Paper' in 
`'D:\Projects\nextjs\resto\node_modules\material-ui-search-bar\lib\components\SearchBar'`

Import trace for requested module:
./node_modules/material-ui-search-bar/lib/components/SearchBar/SearchBar.js
./node_modules/material-ui-search-bar/lib/components/SearchBar/index.js
./node_modules/material-ui-search-bar/lib/index.js
./components/admin/ProductDatatable.jsx
./components/admin/ProductList.jsx

./node_modules/material-ui-search-bar/lib/components/SearchBar/SearchBar.js
Module not found: Can't resolve '@material-ui/icons/Clear' in 
'D:\Projects\nextjs\resto\node_modules\material-ui-search-bar\lib\components\SearchBar'

Import trace for requested module:
./node_modules/material-ui-search-bar/lib/components/SearchBar/SearchBar.js
./node_modules/material-ui-search-bar/lib/components/SearchBar/index.js
./node_modules/material-ui-search-bar/lib/index.js
./components/admin/ProductDatatable.jsx
./components/admin/ProductList.jsx

./node_modules/material-ui-search-bar/lib/components/SearchBar/SearchBar.js
Module not found: Can't resolve '@material-ui/icons/Search' in 
'D:\Projects\nextjs\resto\node_modules\material-ui-search-bar\lib\components\SearchBar'

Import trace for requested module:
./node_modules/material-ui-search-bar/lib/components/SearchBar/SearchBar.js
./node_modules/material-ui-search-bar/lib/components/SearchBar/index.js
./node_modules/material-ui-search-bar/lib/index.js
./components/admin/ProductDatatable.jsx
./components/admin/ProductList.jsx

Build failed because of webpack errors
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

下面是我的package.json

{
    "name": "hfc-resturant", 
    "private": true, 
    "scripts": { 
        "dev": "next dev", 
        "type": "module", 
        "build": "next build", 
        "start": "next start -p 3000", 
        "server": "nodemon start index.js ./backend/auth", 
        "lint": "next lint" 
    }, 
    "dependencies": { 
        "@carbon/react": "^1.15.0", 
        "@emotion/react": "^11.10.4", 
        "@emotion/styled": "^11.10.4", 
        "@mui/icons-material": "^5.10.9", 
        "@mui/material": "^5.10.10", 
        "@mui/x-data-grid": "^5.17.8", 
        "@paypal/react-paypal-js": "^7.8.1", 
        "@react-hook/window-scroll": "^1.3.0", 
        "@reduxjs/toolkit": "^1.8.6", 
        "@testing-library/jest-dom": "^5.16.5", 
        "@testing-library/react": "^13.4.0", 
        "@testing-library/user-event": "^14.4.3", 
        "axios": "^1.1.3", 
        "bcrypt": "^5.1.0", 
        "bootstrap": "^5.2.2", 
        "cookie": "^0.5.0", 
        "cookie-session": "^2.0.0", 
        "cors": "^2.8.5", 
        "dependencies": "^0.0.1", 
        "express": "^4.18.2", 
        "firebase": "^9.12.1", 
        "firebase-admin": "^11.2.0", 
        "firebase-functions": "^4.0.1", 
        "framer-motion": "^7.6.1", 
        "jose": "^4.10.3", 
        "jsonwebtoken": "^8.5.1", 
        "mapbox-gl": "^2.10.0", 
        "material-ui-search-bar": "^1.0.0", 
        "mongoose": "^6.6.6", 
        "next": "^12.3.1", 
        "next-redux-wrapper": "^8.0.0", 
        "nodemon": "^2.0.20", 
        "passport": "^0.6.0", 
        "passport-facebook": "^3.0.0", 
        "passport-github2": "^0.1.12",
         "passport-google-oauth20": "^2.0.0", 
         "react": "^18.2.0", 
         "react-background-slider": "^2.0.0", 
         "react-circular-progressbar": "^2.1.0", 
         "react-copy-to-clipboard": "^5.1.0", 
         "react-dom": "^18.2.0", 
         "react-otp-input": "^2.4.0", 
         "react-redux": "^8.0.4", 
         "react-reveal": "^1.2.2", 
         "react-router-dom": "^6.4.2", 
         "react-scripts": "^5.0.1", 
         "react-scroll": "^1.8.8", 
         "react-scroll-to-component": "^1.0.2", 
         "react-use-window-scroll": "^1.0.14", 
         "reactjs-popup": "^2.0.5", 
         "recharts": "^2.1.15", 
         "redux-devtools-extension": "^2.13.9", 
         "sass": "^1.55.0", 
         "shortid": "^2.2.16", 
         "swiper": "^8.4.4", 
         "terser-webpack-plugin": "^5.3.6", 
         "use-sync-external-store": "^1.2.0", 
         "web-vitals": "^3.0.4" 
    }, 
    "devDependencies": { 
        "@types/cookie": "^0.5.1", 
        "babel-core": "^6.26.3", 
        "babel-loader": "^8.2.5", 
        "babel-preset-env": "^1.7.0", 
        "babel-preset-react": "^6.24.1", 
        "babel-preset-stage-0": "^6.24.1", 
        "eslint": "^8.25.0", 
        "eslint-config-next": "^12.3.1", 
        "html-webpack-plugin": "^5.5.0", 
        "path": "^0.12.7", 
        "webpack": "^5.74.0", 
        "webpack-cli": "^4.10.0", 
        "webpack-dev-server": "^4.11.1"
    }
}

请帮助我确定已安装软件包的正确版本,以便顺利构建应用程序。
我的应用程序在npm run dev期间运行良好。但是,当使用npm run build构建应用程序、使用npm start从构建的文件启动应用程序,或者尝试在Vercel或任何其他提供程序上部署应用程序时,应用程序崩溃。

e5nszbig

e5nszbig1#

注意:如果您仍在使用Material-UI v3,请使用npm i --save material-ui-search-bar@beta安装搜索栏的v0.x

相关问题