折腾:
期间,
看到很多类似于:
npm WARN enoent ENOENT: no such file or directory, open ‘/Users/crifan/dev/dev_root/daryun/Projects/xxx/node_modules/@expo/vector-icons/package.json’
的输出:
➜ rn_rse npm install react-native-elements@0.12.0 > react-native-elements@0.12.0 postinstall /Users/crifan/dev/dev_root/xxx/node_modules/react-native-elements > opencollective postinstall [server error] Cannot load the stats for react-native-elements – please try again later Thanks for installing react-native-elements 🙏 Please consider donating to our open collective to help us maintain this package. – lodash.isempty@4.4.0 node_modules/lodash.isempty rn_rse@0.1.0 /Users/crifan/dev/dev_root/xxx └─┬ react-native-elements@0.12.0 └── react-native-side-menu@0.20.3 npm WARN enoent ENOENT: no such file or directory, open ‘/Users/crifan/dev/dev_root//node_modules/@expo/vector-icons/package.json’ npm WARN enoent ENOENT: no such file or directory, open ‘/Users/crifan/dev/dev_root/daryun/Projects//node_modules/babel-preset-es2015-node/package.json’ npm WARN enoent ENOENT: no such file or directory, open ‘/Users/crifan/dev/dev_root//node_modules/create-react-class/package.json’ npm WARN enoent ENOENT: no such file or directory, open ‘/Users/crifan/dev/dev_root//node_modules/envinfo/package.json’ |
想办法去看看到底怎么回事。
之前记得已经:
npm install
但是还是有这个问题。
或许和之前:
把npm从5.0降版到0.46.1所导致的?
npm WARN enoent ENOENT: no such file or directory, open package.json
npm WARN enoent ENOENT: no such file or directory, open
npm WARN enoent ENOENT: no such file or directory, open ‘<root>/node_modules/supertest/package.json’ · Issue #261 · visionmedia/debug
先去试试:
npm cache clean
再
npm install
➜ rn_rse npm cache clean ➜ rn_rse npm install npm WARN enoent ENOENT: no such file or directory, open ‘/Users/crifan/dev/dev_root/xxxnode_modules/@expo/vector-icons/package.json’ npm WARN enoent ENOENT: no such file or directory, open ‘/Users/crifan/dev/dev_root/xxxnode_modules/babel-preset-es2015-node/package.json’ npm WARN enoent ENOENT: no such file or directory, open ‘/Users/crifan/dev/dev_root/xxxnode_modules/create-react-class/package.json’ npm WARN enoent ENOENT: no such file or directory, open ‘/Users/crifan/dev/dev_root/xxxnode_modules/envinfo/package.json’ npm WARN enoent ENOENT: no such file or directory, open ‘/Users/crifan/dev/dev_root/xxxnode_modules/fbjs-scripts/package.json’ npm WARN enoent ENOENT: no such file or directory, open ‘/Users/crifan/dev/dev_root/xxxnode_modules/find-babel-config/package.json’ npm WARN enoent ENOENT: no such file or directory, open ‘/Users/crifan/dev/dev_root/xxxnode_modules/jest-cli/package.json’ npm WARN enoent ENOENT: no such file or directory, open ‘/Users/crifan/dev/dev_root/xxxnode_modules/lottie-react-native/package.json’ npm WARN enoent ENOENT: no such file or directory, open ‘/Users/crifan/dev/dev_root/xxxnode_modules/metro-bundler/package.json’ npm WARN enoent ENOENT: no such file or directory, open ‘/Users/crifan/dev/dev_root/xxxnode_modules/node-pre-gyp/package.json’ npm WARN enoent ENOENT: no such file or directory, open ‘/Users/crifan/dev/dev_root/xxxnode_modules/react-native-branch/package.json’ npm WARN enoent ENOENT: no such file or directory, open ‘/Users/crifan/dev/dev_root/xxxnode_modules/react-native-gesture-handler/package.json’ npm WARN enoent ENOENT: no such file or directory, open ‘/Users/crifan/dev/dev_root/xxxnode_modules/react-native-maps/package.json’ npm WARN enoent ENOENT: no such file or directory, open ‘/Users/crifan/dev/dev_root/xxxnode_modules/react-native-safe-module/package.json’ npm WARN enoent ENOENT: no such file or directory, open ‘/Users/crifan/dev/dev_root/xxxnode_modules/react-native-svg/package.json’ npm WARN enoent ENOENT: no such file or directory, open ‘/Users/crifan/dev/dev_root/xxxnode_modules/regexpu-core/package.json’ npm WARN enoent ENOENT: no such file or directory, open ‘/Users/crifan/dev/dev_root/xxxnode_modules/tar-pack/package.json’ npm WARN enoent ENOENT: no such file or directory, open ‘/Users/crifan/dev/dev_root/xxxnode_modules/win-release/package.json’ npm WARN enoent ENOENT: no such file or directory, open ‘/Users/crifan/dev/dev_root/xxxnode_modules/xcode/package.json’ npm WARN enoent ENOENT: no such file or directory, open ‘/Users/crifan/dev/dev_root/xxxnode_modules/fbjs-scripts/node_modules/cross-spawn/package.json’ npm WARN enoent ENOENT: no such file or directory, open ‘/Users/crifan/dev/dev_root/xxxnode_modules/metro-bundler/node_modules/fbjs/package.json’ npm WARN enoent ENOENT: no such file or directory, open ‘/Users/crifan/dev/dev_root/xxxnode_modules/metro-bundler/node_modules/jest-haste-map/package.json’ npm WARN enoent ENOENT: no such file or directory, open ‘/Users/crifan/dev/dev_root/xxxnode_modules/node-pre-gyp/node_modules/http-signature/package.json’ npm WARN enoent ENOENT: no such file or directory, open ‘/Users/crifan/dev/dev_root/xxxnode_modules/node-pre-gyp/node_modules/request/package.json’ npm WARN react-native-branch@2.0.0-beta.3 requires a peer of react@>=15.4.0 but none was installed. npm WARN react-native-gesture-handler@1.0.0-alpha.22 requires a peer of react@> 15.0.0 but none was installed. |
问题依旧。
去把本地的node_modules删除掉:
再去试试
npm install
然后卡在:
➜ rn_rse npm install ⸨░░░░░░░░░░░░░░░░░░⸩ ⠋ fetchMetadata: sill mapToRegistry uri https://registry.npm.taobao.org/qs |
最后好像是可以了:
│ │ ├── punycode@1.3.2 │ │ └── querystring@0.2.0 deduped │ ├── uuid@3.1.0 deduped │ ├── xmldom@0.1.27 deduped │ └── yesno@0.0.1 ├─┬ react-navigation@1.0.0-beta.13 │ ├─┬ babel-plugin-transform-define@1.3.0 │ │ ├── lodash@4.17.4 deduped │ │ └── traverse@0.6.6 │ ├── clamp@1.0.1 │ ├── hoist-non-react-statics@2.3.1 │ ├─┬ path-to-regexp@1.7.0 │ │ └── isarray@0.0.1 │ ├── prop-types@15.6.0 deduped │ ├─┬ react-native-drawer-layout-polyfill@1.3.2 │ │ └─┬ react-native-drawer-layout@1.3.2 │ │ └── react-native-dismiss-keyboard@1.0.0 │ └─┬ react-native-tab-view@0.0.69 │ └── prop-types@15.6.0 deduped └─┬ react-test-renderer@16.0.0-alpha.12 ├── fbjs@0.8.16 deduped └── object-assign@4.1.1 deduped npm WARN react-native-gesture-handler@1.0.0-alpha.22 requires a peer of react@> 15.0.0 but none was installed. npm WARN react-native-branch@2.0.0-beta.3 requires a peer of react@>=15.4.0 but none was installed. |
然后再去安装别的库,看看是否还有报错:
npm install react-native-elements –save
好像就没了上面一堆的警告了(虽然本身由于别的原因而报错):
➜ rn_rse npm install react-native-elements –save > react-native-elements@0.17.0 postinstall /Users/crifan/dev/dev_root/xxxnode_modules/react-native-elements > opencollective postinstall [server error] Cannot load the stats for react-native-elements – please try again later Thanks for installing react-native-elements 🙏 Please consider donating to our open collective to help us maintain this package. rn_rse@0.1.0 /Users/crifan/dev/dev_root/xxx └─┬ react-native-elements@0.17.0 ├── lodash.isempty@4.4.0 ├── lodash.times@4.3.2 ├─┬ opencollective@1.0.3 │ ├─┬ babel-polyfill@6.23.0 │ │ ├── core-js@2.5.1 │ │ └── regenerator-runtime@0.10.5 │ ├─┬ inquirer@3.0.6 │ │ ├── ansi-escapes@1.4.0 │ │ ├── rx@4.1.0 │ │ └─┬ string-width@2.1.1 │ │ ├── is-fullwidth-code-point@2.0.0 │ │ └─┬ strip-ansi@4.0.0 │ │ └── ansi-regex@3.0.0 │ ├── node-fetch@1.6.3 │ └── opn@4.0.2 ├── react-native-side-menu@1.1.3 └─┬ react-native-tab-navigator@0.3.4 └── immutable@3.8.2 npm WARN react-native-branch@2.0.0-beta.3 requires a peer of react@>=15.4.0 but none was installed. npm WARN react-native-gesture-handler@1.0.0-alpha.22 requires a peer of react@> 15.0.0 but none was installed. npm WARN react-native-elements@0.17.0 requires a peer of react-native-vector-icons@^4.2.0 but none was installed. |
【总结】
还是多试了试:
npm cache clean
删除项目根目录下的node_modules文件夹,再
npm install
就可以了。还不行的话,就多试试几次。
估计导致上述警告是因为:
之前最开始安装的5.0的npm,后来降级到0.46.1了,所以估计有些版本不兼容?才报错的。
转载请注明:在路上 » 【已解决】npm install期间出错:npm WARN enoent ENOENT: no such file or directory, open node_modules/@expo/vector-icons/package.json