gpt4 book ai didi

reactjs - 从 react 16.2.0 降级到 react 15.6.2 失败

转载 作者:行者123 更新时间:2023-12-04 00:32:23 24 4
gpt4 key购买 nike

我最近从 react 15.6.2 升级到 react 16.2.0现在我的应用程序没有按预期工作,并且对 react 15.6.2 的依赖有很多警告所以对我来说,由于时间安排,现在不可能将所有其他依赖项升级到 16.2.0.。因此我想降级以响应 15.6.2

我运行以下命令再次安装 react 15.6.2:

npm install react@^15.6.2

我收到以下错误:

+-- UNMET PEER DEPENDENCY react@15.6.2 invalid
`-- UNMET PEER DEPENDENCY react-dom@16.2.0

当我将 package.json 更新为 "react": "^15.6.2" 时,出现以下错误:

npm ERR! Linux 3.13.0-36-generic
npm ERR! argv "/home/rakesh/.nvm/versions/node/v6.9.4/bin/node" "/home/rakesh/.nvm/versions/node/v6.9.4/bin/npm" "install"
npm ERR! node v6.9.4
npm ERR! npm v3.10.10
npm ERR! code EBADPLATFORM

npm ERR! notsup Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! notsup Valid OS: darwin
npm ERR! notsup Valid Arch: any
npm ERR! notsup Actual OS: linux
npm ERR! notsup Actual Arch: x64

npm ERR! Please include the following file with any support request:
npm ERR! /home/rakesh/rockethire/development/codebase/recruitment/rh-react/npm-debug.log

下面是我的 package.json

{
"name": "rh-react",
"version": "1.0.0",
"description": "Pages accessible for outside world",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "webpack -d --watch",
"build": "sh -ac '. .env; webpack -d'",
"build:test": "sh -ac '. .env.test; webpack -p'",
"build:prod": "sh -ac '. .env.prod; webpack -p'"
},
"author": "",
"license": "ISC",
"dependencies": {
"ag-grid": "^13.3.1",
"ag-grid-react": "^13.3.0",
"axios": "^0.17.1",
"babel-loader": "^7.1.2",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"bootstrap": "^3.3.7",
"classnames": "^2.2.5",
"dotenv": "^4.0.0",
"fsevents": "^1.1.3",
"jquery": "^3.2.1",
"moment": "^2.19.1",
"query-string": "^5.0.0",
"react": "^16.2.0",
"react-async-script-loader": "^0.3.0",
"react-click-outside": "^3.0.0",
"react-cookies": "^0.1.0",
"react-datepicker": "^0.61.0",
"react-datetime": "^2.11.1",
"react-dom": "^16.2.0",
"react-dom-factories": "^1.0.2",
"react-dropzone": "^4.2.3",
"react-dropzone-component": "^3.0.0",
"react-moment": "^0.6.5",
"react-notifications": "^1.4.3",
"react-nvd3": "^0.5.7",
"react-router": "^2.8.1",
"react-router-dom": "^4.2.2",
"react-scripts": "^1.0.17",
"react-select": "^1.0.0-rc.10",
"react-select2-wrapper": "^1.0.4-beta5",
"reactjs-localstorage": "0.0.5",
"webpack": "^3.9.1",
"whatwg-fetch": "^2.0.3"
},
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-env": "^1.6.0",
"babel-preset-stage-0": "^6.24.1",
"compression-webpack-plugin": "^1.0.1",
"css-loader": "^0.28.7",
"eslint": "^4.11.0",
"eslint-plugin-react": "^7.5.1",
"style-loader": "^0.19.0",
"uglifyjs-webpack-plugin": "^1.1.2",
"webpack": "^3.6.0",
"webpack-bundle-analyzer": "^2.9.1"
}
}

有人知道为什么我无法降级吗?

最佳答案

我在 @HarshMakadia@nkr 的帮助下解决了这个问题。感谢他们俩。这是任何其他面临相同问题的人的解决方案。

1.删除/重命名您当前的 node_modules 文件夹。
2.运行npm cache clean/sudo npm cache clean(Ubuntu 14.04)
3.手动更新您的 package.json 以将 react 和 react-dom 的版本从 16.0.2 更改为 15.6.2
4.运行npm install/sudo npm install(Ubuntu 14.04)

注意:将您的 node_modules 文件夹添加到任何 VCS(如 git)以防止此类问题

关于reactjs - 从 react 16.2.0 降级到 react 15.6.2 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49252594/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com