我不小心删除了我的node_modules
文件夹。我知道恢复它的方法只是运行npm install
但这在我的情况下不起作用。它在我的JSON
文件中说错了。我在Terminal
收到此错误。
这是我的Package.js
文件:
{
"name": "App",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"aws-sdk": "git://github.com/aws/aws-sdk-js.git#react-native",
"react": "^16.0.0-alpha.12",
"react-native": "^0.45.1",
"react-native-aws-signature": "0.0.9",
"react-native-dropdown-menu": "^1.1.0",
"react-native-dynamodb": "0.0.5",
"react-redux": "^5.0.5",
"redux": "^3.7.1"
},
"devDependencies": {
"babel-jest": "20.0.3",
"babel-preset-react-native": "2.0.0",
"jest": "20.0.4",
"react-test-renderer": "16.0.0-alpha.12"
},
"jest": {
"preset": "react-native"
},
}
错误:
Failed to parse package.json data.
npm ERR! package.json must be actual JSON, not just JavaScript.
npm ERR!
npm ERR! This is not a bug in npm.
npm ERR! Tell the package author to fix their package.json file. JSON.parse
npm ERR! Please include the following file with any support request:
答案 0 :(得分:3)
第27行有一个错误,这里有足够的,
是有效的json
{
"name": "TorusTApp",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"aws-sdk": "git://github.com/aws/aws-sdk-js.git#react-native",
"react": "^16.0.0-alpha.12",
"react-native": "^0.45.1",
"react-native-aws-signature": "0.0.9",
"react-native-dropdown-menu": "^1.1.0",
"react-native-dynamodb": "0.0.5",
"react-redux": "^5.0.5",
"redux": "^3.7.1"
},
"devDependencies": {
"babel-jest": "20.0.3",
"babel-preset-react-native": "2.0.0",
"jest": "20.0.4",
"react-test-renderer": "16.0.0-alpha.12"
},
"jest": {
"preset": "react-native"
}
}
答案 1 :(得分:1)
我相信这是因为你的package.js文件中的倒数第二行有一个额外的逗号。
答案 2 :(得分:0)
通过json验证器在线运行此json。例如https://jsonlint.com/
之前的回答是正确的,但这将在未来帮助你。