有人可以告诉我我的package.json文件出了什么问题吗?

问题描述

我有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并重新完成npm init,并在添加"start": "electron ."后即可正常工作。

我将不再尝试对其进行编辑...

,

问题出在文件的“关键字”部分,您应该用[]而不是{}包围关键字。

例如:

...
"keywords": [
    "obs","broadcast","open source","Free","Streaming"
],...

如果您想了解JSON格式的工作原理,请访问以下网站:https://www.json.org/json-en.html

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...