有人可以告诉我我的 package.json 文件有什么问题吗?
Can someone please tell me what is wrong with my package.json file?
我已经让 npm 和一个 json 验证器站点告诉我我的 package.jason 文件无效。我浏览了论坛和堆栈溢出,似乎没有什么可以解决的。这是代码:
{
"name": "linobs",
"version": "1.0.0",
"description": "A linux streaming software",
"main": "main.js",
"scripts": {
"test": "linobstest",
"start": "electron ."
},
"keywords": {
"obs",
"broadcast",
"open source",
"Free",
"Streaming"
},
"author": "Dustin Hacker",
"license": "ISC"
}
来自网站的错误消息:
{
"valid": false,
"critical": "Invalid JSON - SyntaxError: JSON.parse: expected ':' after property name in object at line 11 column 6 of the JSON data"
}
来自 npm 的错误消息:
npm ERR! code EJSONPARSE
npm ERR! file /home/ldhacker/Documents/Electron Project/package.json
npm ERR! JSON.parse Failed to parse json
npm ERR! JSON.parse Unexpected token , in JSON at position 183 while parsing near '...
npm ERR! JSON.parse "keywords": {
npm ERR! JSON.parse "OBS",
npm ERR! JSON.parse "Broadcast",
npm ERR! JSON.parse "Open...'
npm ERR! JSON.parse Failed to parse package.json data.
npm ERR! JSON.parse package.json must be actual JSON, not just JavaScript.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/ldhacker/.npm/_logs/2020-09-13T18_38_47_283Z-debug.log
提前致谢!
编辑:
删除了 "main": "main.js",
之后的 ,
现在我得到:
npm ERR! code EJSONPARSE
npm ERR! file /home/ldhacker/Documents/Electron Project/package.json
npm ERR! JSON.parse Failed to parse json
npm ERR! JSON.parse Unexpected string in JSON at position 103 while parsing '{
npm ERR! JSON.parse "name": "linobs",
npm ERR! JSON.parse "version": "1.0.0",
npm ERR! JSON.parse '
npm ERR! JSON.parse Failed to parse package.json data.
npm ERR! JSON.parse package.json must be actual JSON, not just JavaScript.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/ldhacker/.npm/_logs/2020-09-13T19_13_16_582Z-debug.log
刚刚将我的 package.json
重命名为 package.json.old
和 re-accomplished npm init
并且在添加 "start": "electron ."
.
后它起作用了
我不会尝试再次编辑它...
问题出在文件的“关键字”部分,您应该用 []
将关键字括起来,而不是 {}
。
例如:
...
"keywords": [
"obs",
"broadcast",
"open source",
"Free",
"Streaming"
],
...
如果您有兴趣了解 JSON 格式的工作原理,请查看此网站:https://www.json.org/json-en.html
我已经让 npm 和一个 json 验证器站点告诉我我的 package.jason 文件无效。我浏览了论坛和堆栈溢出,似乎没有什么可以解决的。这是代码:
{
"name": "linobs",
"version": "1.0.0",
"description": "A linux streaming software",
"main": "main.js",
"scripts": {
"test": "linobstest",
"start": "electron ."
},
"keywords": {
"obs",
"broadcast",
"open source",
"Free",
"Streaming"
},
"author": "Dustin Hacker",
"license": "ISC"
}
来自网站的错误消息:
{
"valid": false,
"critical": "Invalid JSON - SyntaxError: JSON.parse: expected ':' after property name in object at line 11 column 6 of the JSON data"
}
来自 npm 的错误消息:
npm ERR! code EJSONPARSE
npm ERR! file /home/ldhacker/Documents/Electron Project/package.json
npm ERR! JSON.parse Failed to parse json
npm ERR! JSON.parse Unexpected token , in JSON at position 183 while parsing near '...
npm ERR! JSON.parse "keywords": {
npm ERR! JSON.parse "OBS",
npm ERR! JSON.parse "Broadcast",
npm ERR! JSON.parse "Open...'
npm ERR! JSON.parse Failed to parse package.json data.
npm ERR! JSON.parse package.json must be actual JSON, not just JavaScript.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/ldhacker/.npm/_logs/2020-09-13T18_38_47_283Z-debug.log
提前致谢!
编辑:
删除了 "main": "main.js",
之后的 ,
现在我得到:
npm ERR! code EJSONPARSE
npm ERR! file /home/ldhacker/Documents/Electron Project/package.json
npm ERR! JSON.parse Failed to parse json
npm ERR! JSON.parse Unexpected string in JSON at position 103 while parsing '{
npm ERR! JSON.parse "name": "linobs",
npm ERR! JSON.parse "version": "1.0.0",
npm ERR! JSON.parse '
npm ERR! JSON.parse Failed to parse package.json data.
npm ERR! JSON.parse package.json must be actual JSON, not just JavaScript.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/ldhacker/.npm/_logs/2020-09-13T19_13_16_582Z-debug.log
刚刚将我的 package.json
重命名为 package.json.old
和 re-accomplished npm init
并且在添加 "start": "electron ."
.
我不会尝试再次编辑它...
问题出在文件的“关键字”部分,您应该用 []
将关键字括起来,而不是 {}
。
例如:
...
"keywords": [
"obs",
"broadcast",
"open source",
"Free",
"Streaming"
],
...
如果您有兴趣了解 JSON 格式的工作原理,请查看此网站:https://www.json.org/json-en.html