如果我删除了我的node_modules并在我的ReactNative项目中执行了一个干净的npm安装,我收到警告“react-native@0.37.0需要一个react @〜15.3.1的对等,但没有安装 . ”但是,我已经在package.json文件中将其列为依赖项:
{
"name": "MyApp",
"version": "1.1.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start"
},
"dependencies": {
"lodash": "^4.17.2",
"moment": "^2.16.0",
"react": "^15.3.1",
"react-native": "^0.37.0",
"react-native-drawer": "^2.2.6",
"react-native-htmlview": "^0.5.0",
"react-native-keyboard-spacer": "^0.3.0",
"react-native-material-design": "^0.3.7",
"react-native-modal-picker": "0.0.16",
"react-native-modalbox": "^1.3.4",
"react-native-vector-icons": "^3.0.0",
"react-native-viewpager": "^0.2.13",
"rebound": "0.0.13"
}
}
1 回答
您的
react
依赖版本是^15.3.1
. semver中的插入符号^
允许版本major.minor.patch的次要范围内的任何版本 . NPM目前将此解析为15.4.2
.另一方面,React Native中的
react
对等依赖项是~15.3.1
. 波浪号字符~
仅允许修补程序版本内的变化,因此它与15.4.2
不兼容 .将您的反应依赖项定义为
~15.3.1
,您将获得正确的版本 .