package.json must be actual JSON, not just JavaScript

ε祈祈猫儿з 提交于 2020-08-02 06:05:30

问题


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

  1. There is a short suggestion that I learned from this segment is to put just {} in the package.json file. I didn't try that but I believe that would work.

  2. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!