问题
I used http://jsonlint.com/ to check the syntax for this package.json file
{
"name": "hello-world",
"description": "hello world test app",
"version": "0.0.1",
"private": true,
"dependencies": {
"express": “4.6.1"
}
}
it returns the error
Parse error on line 7:
... "express": “4.6.1" }}
----------------------^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['
not sure what is wrong with this. terminal is throwing the error for using npm install
"Failed to parse package.json data.
npm ERR! package.json must be actual JSON, not just JavaScript."
回答1:
Just type npm cache clean
on prompt and all the things must to work again.
回答2:
You have curly quotes before the 4 - “4.6.1"
. Change that to a regular quote character and it'll pass.
回答3:
package.json file should not be empty.
If you have empty package json file just add {}.
and try again.
回答4:
It's a general syntax error message. Received the same error when a comma was missing in my code. Just running npm cache clean won't work if there's a glitch in the code. I added the missing comma and the program ran to success.
回答5:
I had got this same type of error. The answer, npm cache clean
once solved my question but I got stuck for another reason while installing express.js
There is a short suggestion that I learned from this segment is to put just
{}
in thepackage.json
file. I didn't try that but I believe that would work.I have did another work.
I typed npm init
and then put some description on this file like project name, author, version etc. Then I have terminated. And that made my file the real JSON Format.
And I had my problem solved.
来源:https://stackoverflow.com/questions/24920142/package-json-must-be-actual-json-not-just-javascript