如果我删除我的node_modules并在我的ReactNative项目中执行一次干净的npm安装,我得到警告"react-native@0.37.0需要一个react@~15.3.1的对等体,但没有安装。“但是,我在package.json文件中将react列为依赖项:
{
"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"
}
}发布于 2017-01-20 23:12:54
您的react依赖项版本为^15.3.1。semver中的插入字符^允许在version major.minor.patch的次要范围内的任何版本。NPM目前将其解析为15.4.2。
另一方面,React Native中的react对等依赖项是~15.3.1。波浪号字符~只允许在补丁版本中变化,所以它与15.4.2不兼容。
将您的react依赖项定义为~15.3.1,您将获得正确的版本。
https://stackoverflow.com/questions/41766575
复制相似问题