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

posted @ 2020-07-21 09:43  Shaw_喆宇  阅读(2244)  评论(0编辑  收藏  举报