NodeJS 在升级React后,由于依赖关系,部署React应用程序失败

0yycz8jy  于 2023-08-04  发布在  Node.js
关注(0)|答案(3)|浏览(126)

在将React升级到v18之后,我面临着部署它的问题。我做了文档中描述的一切,搜索了董事会,并不断尝试更改内容以使部署再次工作,但它没有。
我得到以下错误:

$ npm i
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: eslint-plugin-jest@25.7.0
npm WARN Found: @typescript-eslint/eslint-plugin@6.2.1
npm WARN node_modules/@typescript-eslint/eslint-plugin
npm WARN   dev @typescript-eslint/eslint-plugin@"^6.2.1" from the root project
npm WARN 
npm WARN Could not resolve dependency:
npm WARN peerOptional @typescript-eslint/eslint-plugin@"^4.0.0 || ^5.0.0" from eslint-plugin-jest@25.7.0
npm WARN node_modules/eslint-plugin-jest
npm WARN   eslint-plugin-jest@"^25.3.0" from eslint-config-react-app@7.0.1
npm WARN   node_modules/eslint-config-react-app
npm WARN 
npm WARN Conflicting peer dependency: @typescript-eslint/eslint-plugin@5.62.0
npm WARN node_modules/@typescript-eslint/eslint-plugin
npm WARN   peerOptional @typescript-eslint/eslint-plugin@"^4.0.0 || ^5.0.0" from eslint-plugin-jest@25.7.0
npm WARN   node_modules/eslint-plugin-jest
npm WARN     eslint-plugin-jest@"^25.3.0" from eslint-config-react-app@7.0.1
npm WARN     node_modules/eslint-config-react-app
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: react-scripts@5.0.1
npm ERR! Found: typescript@5.1.6
npm ERR! node_modules/typescript
npm ERR!   dev typescript@"^5.1.6" from the root project
npm ERR!   peer typescript@">= 2.7" from fork-ts-checker-webpack-plugin@6.5.2
npm ERR!   node_modules/fork-ts-checker-webpack-plugin
npm ERR!     fork-ts-checker-webpack-plugin@"^6.5.0" from react-dev-utils@12.0.1
npm ERR!     node_modules/react-dev-utils
npm ERR!       react-dev-utils@"^12.0.1" from react-scripts@5.0.1
npm ERR!       node_modules/react-scripts
npm ERR!         dev react-scripts@"5.0.1" from the root project
npm ERR!   2 more (ts-api-utils, tsutils)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peerOptional typescript@"^3.2.1 || ^4" from react-scripts@5.0.1
npm ERR! node_modules/react-scripts
npm ERR!   dev react-scripts@"5.0.1" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: typescript@4.9.5
npm ERR! node_modules/typescript
npm ERR!   peerOptional typescript@"^3.2.1 || ^4" from react-scripts@5.0.1
npm ERR!   node_modules/react-scripts
npm ERR!     dev react-scripts@"5.0.1" from the root project

字符串
知道为什么会这样吗
我的package.json看起来像这样:

{
    "name": "webapp-pwa",
    "version": "0.1.0",
    "private": true,
    "engines": {
        "node": ">=16.14.0",
        "npm": ">=8.5.0"
    },
    "dependencies": {
        "@apollo/client": "^3.7.17",
        "@capacitor-community/barcode-scanner": "^4.0.1",
        "@capacitor/android": "^5.2.2",
        "@capacitor/app": "^5.0.6",
        "@capacitor/core": "^5.2.2",
        "@capacitor/filesystem": "^5.1.1",
        "@capacitor/geolocation": "^5.0.6",
        "@capacitor/ios": "^5.2.2",
        "@capacitor/share": "^5.0.6",
        "@capacitor/status-bar": "^5.0.6",
        "@capawesome/capacitor-screen-orientation": "^5.0.0",
        "@date-io/moment": "^2.17.0",
        "@emotion/react": "^11.11.1",
        "@emotion/styled": "^11.11.0",
        "@fontsource/inter": "^5.0.5",
        "@hookform/resolvers": "^3.1.1",
        "@mui/icons-material": "^5.14.3",
        "@mui/lab": "^5.0.0-alpha.95",
        "@mui/material": "^5.14.3",
        "@mui/x-date-pickers": "^5.0.0-beta.5",
        "@sentry/capacitor": "^0.12.2",
        "@stripe/react-stripe-js": "^2.1.1",
        "@stripe/stripe-js": "^1.54.2",
        "apollo-upload-client": "^17.0.0",
        "caniuse-lite": "^1.0.30001518",
        "capacitor-ios-autofill-save-password": "^1.1.5",
        "env-cmd": "^10.1.0",
        "gleap": "^11.0.8",
        "i18next": "^23.4.1",
        "i18next-browser-languagedetector": "^7.1.0",
        "i18next-http-backend": "^2.2.1",
        "jwt-decode": "^3.1.2",
        "lodash": "^4.17.21",
        "moment": "^2.29.1",
        "node": "^19.8.1",
        "pulltorefreshjs": "^0.1.22",
        "qr-scanner": "^1.4.2",
        "query-string": "^8.1.0",
        "react": "^18.2.0",
        "react-dom": "^18.2.0",
        "react-hook-form": "^7.45.2",
        "react-i18next": "^13.0.3",
        "react-player": "^2.12.0",
        "react-qrcode-logo": "^2.9.0",
        "react-router-dom": "^6.14.2",
        "react-swipeable": "^7.0.1",
        "smoothscroll-polyfill": "^0.4.4",
        "swiper": "^10.1.0",
        "victory": "^36.6.11",
        "yup": "^1.2.0"
    },
    "devDependencies": {
        "@capacitor/cli": "^5.2.2",
        "@graphql-codegen/cli": "^5.0.0",
        "@graphql-codegen/typescript-document-nodes": "^4.0.1",
        "@graphql-codegen/typescript-operations": "^4.0.1",
        "@graphql-codegen/typescript-react-apollo": "^3.3.7",
        "@graphql-codegen/typescript-resolvers": "^4.0.1",
        "@testing-library/jest-dom": "^5.17.0",
        "@testing-library/react": "^14.0.0",
        "@testing-library/user-event": "^14.4.3",
        "@trivago/prettier-plugin-sort-imports": "^4.2.0",
        "@types/apollo-upload-client": "^17.0.2",
        "@types/jest": "^29.5.3",
        "@types/lodash": "^4.14.196",
        "@types/node": "^20.4.5",
        "@types/pulltorefreshjs": "^0.1.5",
        "@types/react": "^18.2.18",
        "@types/react-dom": "^18.2.7",
        "@types/react-router-dom": "^5.1.7",
        "@types/smoothscroll-polyfill": "^0.3.1",
        "@types/victory": "^35.0.0",
        "@types/yup": "^0.32.0",
        "@typescript-eslint/eslint-plugin": "^6.2.1",
        "@typescript-eslint/parser": "^6.2.1",
        "eslint": "^8.46.0",
        "eslint-config-prettier": "^8.9.0",
        "eslint-plugin-prettier": "^5.0.0",
        "eslint-plugin-react-hooks": "^4.6.0",
        "husky": "^8.0.3",
        "lint-staged": "^13.2.3",
        "npm-check-updates": "^16.10.17",
        "prettier": "^3.0.0",
        "pretty-quick": "^3.1.0",
        "react-scripts": "5.0.1",
        "typescript": "^5.1.6"
    }
}

tvmytwxo

tvmytwxo1#

看起来这可能是ESLint依赖版本的问题。尝试运行npm install eslint@latest eslint-config-next@latest
如果这不起作用,请尝试卸载所有deps并重新运行npm install

7kjnsjlb

7kjnsjlb2#

我注意到你粘贴的错误抱怨你的TypeScript版本。我建议将你的TypeScript降级到版本4。一种方法是更改行:

"typescript": "^5.1.6"

字符串

"typescript": "^4.0.0"


完成后,请删除node_modulespackage-lock.json,运行:

npm install


我想这可能会解决你的问题。

a14dhokn

a14dhokn3#

我的package.json看起来像这样:

{
    "name": "webapp-pwa",
    "version": "0.1.0",
    "private": true,
    "engines": {
        "node": ">=16.14.0",
        "npm": ">=8.5.0"
    },
    "dependencies": {
        "@apollo/client": "^3.7.17",
        "@capacitor-community/barcode-scanner": "^4.0.1",
        "@capacitor/android": "^5.2.2",
        "@capacitor/app": "^5.0.6",
        "@capacitor/core": "^5.2.2",
        "@capacitor/filesystem": "^5.1.1",
        "@capacitor/geolocation": "^5.0.6",
        "@capacitor/ios": "^5.2.2",
        "@capacitor/share": "^5.0.6",
        "@capacitor/status-bar": "^5.0.6",
        "@capawesome/capacitor-screen-orientation": "^5.0.0",
        "@date-io/moment": "^2.17.0",
        "@emotion/react": "^11.11.1",
        "@emotion/styled": "^11.11.0",
        "@fontsource/inter": "^5.0.5",
        "@hookform/resolvers": "^3.1.1",
        "@mui/icons-material": "^5.14.3",
        "@mui/lab": "^5.0.0-alpha.95",
        "@mui/material": "^5.14.3",
        "@mui/x-date-pickers": "^5.0.0-beta.5",
        "@sentry/capacitor": "^0.12.2",
        "@stripe/react-stripe-js": "^2.1.1",
        "@stripe/stripe-js": "^1.54.2",
        "apollo-upload-client": "^17.0.0",
        "caniuse-lite": "^1.0.30001518",
        "capacitor-ios-autofill-save-password": "^1.1.5",
        "env-cmd": "^10.1.0",
        "gleap": "^11.0.8",
        "i18next": "^23.4.1",
        "i18next-browser-languagedetector": "^7.1.0",
        "i18next-http-backend": "^2.2.1",
        "jwt-decode": "^3.1.2",
        "lodash": "^4.17.21",
        "moment": "^2.29.1",
        "node": "^19.8.1",
        "pulltorefreshjs": "^0.1.22",
        "qr-scanner": "^1.4.2",
        "query-string": "^8.1.0",
        "react": "^18.2.0",
        "react-dom": "^18.2.0",
        "react-hook-form": "^7.45.2",
        "react-i18next": "^13.0.3",
        "react-player": "^2.12.0",
        "react-qrcode-logo": "^2.9.0",
        "react-router-dom": "^6.14.2",
        "react-swipeable": "^7.0.1",
        "smoothscroll-polyfill": "^0.4.4",
        "swiper": "^10.1.0",
        "victory": "^36.6.11",
        "yup": "^1.2.0"
    },
    "devDependencies": {
        "@capacitor/cli": "^5.2.2",
        "@graphql-codegen/cli": "^5.0.0",
        "@graphql-codegen/typescript-document-nodes": "^4.0.1",
        "@graphql-codegen/typescript-operations": "^4.0.1",
        "@graphql-codegen/typescript-react-apollo": "^3.3.7",
        "@graphql-codegen/typescript-resolvers": "^4.0.1",
        "@testing-library/jest-dom": "^5.17.0",
        "@testing-library/react": "^14.0.0",
        "@testing-library/user-event": "^14.4.3",
        "@trivago/prettier-plugin-sort-imports": "^4.2.0",
        "@types/apollo-upload-client": "^17.0.2",
        "@types/jest": "^29.5.3",
        "@types/lodash": "^4.14.196",
        "@types/node": "^20.4.5",
        "@types/pulltorefreshjs": "^0.1.5",
        "@types/react": "^18.2.18",
        "@types/react-dom": "^18.2.7",
        "@types/react-router-dom": "^5.1.7",
        "@types/smoothscroll-polyfill": "^0.3.1",
        "@types/victory": "^35.0.0",
        "@types/yup": "^0.32.0",
        "@typescript-eslint/eslint-plugin": "^6.2.1",
        "@typescript-eslint/parser": "^6.2.1",
        "eslint": "^8.46.0",
        "eslint-config-prettier": "^8.9.0",
        "eslint-plugin-prettier": "^5.0.0",
        "eslint-plugin-react-hooks": "^4.6.0",
        "husky": "^8.0.3",
        "lint-staged": "^13.2.3",
        "npm-check-updates": "^16.10.17",
        "prettier": "^3.0.0",
        "pretty-quick": "^3.1.0",
        "react-scripts": "5.0.1",
        "typescript": "^5.1.6"
    }
}

字符串

相关问题