node.js package.json 必须是实际的 JSON,而不仅仅是 JavaScript
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24920142/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
package.json must be actual JSON, not just JavaScript
提问by nmolloy93
I used http://jsonlint.com/to check the syntax for this package.json file
我使用http://jsonlint.com/来检查这个 package.json 文件的语法
{
"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
不知道这有什么问题。终端抛出使用 npm install 的错误
"Failed to parse package.json data.
npm ERR! package.json must be actual JSON, not just JavaScript."
回答by Eduardo Raupp Pereira
Just type npm cache cleanon prompt and all the things must to work again.
只需输入npm cache clean提示,所有的事情都必须再次工作。
回答by glortho
You have curly quotes before the 4 - “4.6.1". Change that to a regular quote character and it'll pass.
您在 4 - 之前有卷曲引号“4.6.1"。将其更改为常规引号字符,它将通过。
回答by Lijo
回答by Yusuf
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.
这是一般的语法错误消息。当我的代码中缺少逗号时收到相同的错误。如果代码中存在故障,仅运行 npm cache clean 将不起作用。我添加了缺少的逗号,程序运行成功。
回答by Osman Gani Khan Masum
I had got this same type of error. The answer, npm cache cleanonce solved my question but I got stuck for another reason while installing express.js
我遇到了同样类型的错误。答案,npm cache clean曾经解决了我的问题,但我在安装时由于另一个原因卡住了express.js
There is a short suggestion that I learned from this segment is to put just
{}in thepackage.jsonfile. I didn't try that but I believe that would work.I have did another work.
我从这部分学到的一个简短建议是只
{}放在package.json文件中。我没有尝试过,但我相信那会奏效。我做了另一项工作。
I typed npm initand then put some description on this file like project name, author, versionetc. Then I have terminated. And that made my file the real JSON Format.And I had my problem solved.
我打字npm init,然后在这个文件上加上一些描述,比如项目名称、作者、版本等。然后我就终止了。这使我的文件成为真实的JSON Format.我解决了我的问题。


