2017-05-08 159 views
-4

npm錯誤,當我嘗試用Mac構建React Native環境時。sudo npm install -g react-native ERR!無法找到模塊'./spawn'


0 info it worked if it ends with ok 
1 verbose cli [ '/usr/local/bin/node', 
1 verbose cli '/usr/local/bin/npm', 
1 verbose cli 'install', 
1 verbose cli '-g', 
1 verbose cli 'react-native' ] 
2 info using [email protected] 
3 info using [email protected] 
4 verbose stack Error: Cannot find module './spawn' 
4 verbose stack  at Function.Module._resolveFilename (module.js:325:15) 
4 verbose stack  at Function.Module._load (module.js:276:25) 
4 verbose stack  at Module.require (module.js:353:17) 
4 verbose stack  at require (internal/module.js:12:17) 
4 verbose stack  at Object.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:6:13) 
4 verbose stack  at Module._compile (module.js:409:26) 
4 verbose stack  at Object.Module._extensions..js (module.js:416:10) 
4 verbose stack  at Module.load (module.js:343:32) 
4 verbose stack  at Function.Module._load (module.js:300:12) 
4 verbose stack  at Module.require (module.js:353:17) 
4 verbose stack  at require (internal/module.js:12:17) 
5 verbose cwd /Users/BigGIfts 
6 error Darwin 15.6.0 
7 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "react-native" 
8 error node v4.6.0 
9 error npm v2.15.9 
10 error code MODULE_NOT_FOUND 
11 error Cannot find module './spawn' 
12 error If you need help, you may report this error at: 
12 error  <https://github.com/npm/npm/issues> 
13 verbose exit [ 1, true ] 

回答

0

打造react-native的正確方法:

npm install -g react-native-cli 

如果你得到這樣的錯誤:

Cannot find module 'npmlog' 

嘗試直接安裝NPM:curl -0 -L https://npmjs.org/install.sh | sudo sh

注意:當錯誤日誌中的任何地方出現錯誤cannot find ...並且您確實安裝了它時,可能是在錯誤的目錄中,或者您尚未安裝它。

希望這可以幫助你;)

相關問題