从0.57升级到React Native
0.58.5后,每安装npm
模块都会出现错误:
npm WARN react-native@0.58.5 requires a peer of react@16.6.3 but none is installed. You must install peer dependencies yourself.
npm ERR! path C:\d\code\js\emps\node_modules\colors
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename 'C:\d\code\js\emps\node_modules\colors' -> 'C:\d\code\js\emps\node_modules\.colors.DELETE'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\JunC\AppData\Roaming\npm-cache\_logs\2019-02-25T23_49_59_940Z-debug.log
这是package.json
的一部分:
"dependencies": {
"react": "^16.8.2",
"react-native": "^0.58.5",
"react-native-code-push": "^5.5.2",
"react-native-device-info": "^0.26.4",
"react-native-gifted-chat": "^0.7.2",
"react-navigation": "^3.3.0"
},
react
版本是reareay 16.8.2
,它比消息提示的要新。是什么导致错误消息? react-native
是否太新了?
答案 0 :(得分:1)
与npm ERR!
相关,您需要运行npm install color -S
,因为json文件中缺少color
软件包。
希望这会有所帮助!
答案 1 :(得分:0)
我最终重新安装了整个系统,并注意到react版本被锁定在16.6.2,而不是最新版本(16.8.2)。问题可能是由较新的反应引起的不兼容问题。重新安装后,这是package.json
的一部分:
"dependencies": {
"react": "16.6.3",
"react-native": "0.58.5",
"react-native-code-push": "^5.5.2",
"react-native-device-info": "^0.26.4",
"react-native-gifted-chat": "^0.7.2",
"react-native-navigation": "^2.12.0",
"react-navigation": "^3.3.2"
},
"devDependencies": {
"babel-core": "7.0.0-bridge.0",
"babel-jest": "24.1.0",
"jest": "24.1.0",
"metro-react-native-babel-preset": "0.52.0",
"react-test-renderer": "16.6.3"
},
"jest": {
"preset": "react-native"
}