[英]Why is npm not installing react from package.json?
如果我刪除我的 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"
}
}
你的react
依賴版本是^15.3.1
。 semver 中的插入字符^
允許版本 Major.minor.patch 的次要范圍內的任何版本。 NPM 目前將其解決為15.4.2
。
另一方面,React Native 中的react
peer 依賴是~15.3.1
。 波浪號字符~
只允許在補丁版本中變化,所以它與15.4.2
不兼容。
將您的 react 依賴項定義為~15.3.1
,您將獲得正確的版本。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.