運行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
。