npm build 出錯:Unexpected string in JSON while parsing


運行npm run build報錯:

18 error JSON.parse Failed to parse json
18 error JSON.parse Unexpected string in JSON at position 169 while parsing '{
18 error JSON.parse   "name": "my-test-package",
18 error JSON.parse   "versio'
19 error JSON.parse Failed to parse package.json data.
19 error JSON.parse package.json must be actual JSON, not just JavaScript.

解決:
json內部寫錯了,我是少了一個comma。

  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1", //這里兩行間的逗號
	"build": "webpack --config ./webpack.config.js"
  },

如果格式沒有問題,可能是package-lock.json文件損壞,刪了文件重新 npm install


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM