Reputation: 1619
I have a frequent problem with npm, it occurs when running npm start
command in a react project folder after some time not working with that project.
I get several lines of log include 'Failed to parse json' and 'package.json must be actual JSON, not just Javascript'.
The problem always happen after i get to deal with the project after some weeks of no-use, my package.json file seems fine and this is an example
{
"name": "carzyGame",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.4.2",
"react-dom": "^16.4.2",
"react-scripts": "1.1.4",
"redux": "^4.0.0",
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
}
}
another one:
{
"name": "neighborhood",
"version": "0.1.0",
"private": true,
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
"dependencies": {
"escape-string-regexp": "^1.0.5",
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-foursquare": "^1.0.3",
"react-scripts": "1.1.4",
"sort-by": "^1.2.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
I tried to uninstall npm by npm uninstall
and i got the same error, also removing node modules file could not help (the purpose is to re-install it).
So what is the reason of that problem and how to solve it?
Upvotes: 0
Views: 2212
Reputation: 8165
The faulty lines are:
"redux": "^4.0.0",
"eject": "react-scripts eject",
Unlike in JavaScript, a trailing comma is not allowed in the last key-value pair of a JSON object.
Upvotes: 1