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