【发布时间】:2017-05-20 18:58:17
【问题描述】:
我发现当我在 react native 项目的根目录下运行 npm install 时,它总是向我显示警告:
npm WARN enoent ENOENT:没有这样的文件或目录,打开 '/Users/chen/Documents/react-native/project/node_modules/node_modules/package.json'
但我们知道 package.json 应该在 node_modules 文件夹下
这是我在项目根目录中的package.json
{
"name": "project",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest",
"bundle-ios": "node node_modules/react-native/local-cli/cli.js bundle --entry-file index.ios.js --platform ios --dev false --bundle-output ./ios/bundle/index.ios.jsbundle --assets-dest ./ios/bundle"
},
"dependencies": {
"react": "~15.4.0-rc.4",
"react-native": "0.40.0",
"react-native-elements": "^0.9.0",
"react-native-scrollable-tab-view": "^0.7.0",
"react-native-swiper": "^1.5.4",
"react-native-vector-icons": "^4.0.0"
},
"devDependencies": {
"babel-jest": "18.0.0",
"babel-preset-react-native": "1.9.1",
"jest": "18.1.0",
"react-test-renderer": "~15.4.0-rc.4"
},
"jest": {
"preset": "react-native"
}
}
这个 json 一切正常,运行 npm install 后,该库将附加依赖项。
并且在node_modules文件夹中还有另一个package.json,当我运行npm install时这个json不会更新,错误说它指向node_modules/node_modules/package.json,当然不存在这个文件
{
"dependencies": {
"react-native-scrollable-tab-view": "^0.7.0",
"react-native-swiper": "^1.5.4",
"react-native-vector-icons": "^4.0.0",
"react-native-elements": "^0.9.0"
}
}
那么 npm install 是如何找到错误路径的呢??
【问题讨论】:
标签: node.js npm npm-install package.json