簡體   English   中英

有人可以告訴我我的 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並重新完成npm init並在添加"start": "electron ."后工作"start": "electron ." .

我不會再嘗試編輯它...

問題出在文件的“關鍵字”部分,您應該用[]而不是{}將關鍵字括起來。

例如:

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

如果您有興趣了解 JSON 格式的工作原理,請查看此網站: https : //www.json.org/json-en.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM