2017-01-20 142 views
0

如果我刪除我的node_modules並在我的ReactNative項目中執行乾淨的npm安裝,我會收到警告:「[email protected]需要[email protected]~15.3.1的同行,但沒有安裝任何東西。」不過,我反應過來列爲的package.json文件的依賴性:爲什麼npm沒有安裝從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,您將獲得正確的版本。

+0

有道理!謝謝薄荷。 –

相關問題