npm install --save で JSON.parse エラーが出る場合は package.json が壊れているので 空 JSON でも書き込もう #npm #node


Error

$ npm install --save puppeteer
npm ERR! file /Users/yumainaura/.ghq/github.com/GuildWorks/insides/insides-api/package.json
npm ERR! code EJSONPARSE
npm ERR! JSON.parse Failed to parse json
npm ERR! JSON.parse Unexpected end of JSON input while parsing near ''
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!     /Users/yumainaura/.npm/_logs/2019-11-04T04_04_46_126Z-debug.log

解決

echo '{}' > package.json

npm install --save puppeteer

Original by Github issue