ProjectStack
npm

npm ERR! code EJSONPARSE — Failed to parse JSON

npm tried to read package.json or package-lock.json and found invalid JSON syntax. A single misplaced comma, missing quote, or bracket will break the entire file.

Common causes

  • A trailing comma after the last item in an object or array (not valid in JSON, only in JS)
  • A missing or extra closing bracket or brace
  • Smart quotes (“”) copied from a document instead of straight quotes ("")
  • A merge conflict left conflict markers (<<<<<<<) inside the JSON file

How to fix it

  1. Validate your package.json online at jsonlint.com or run: node -e "JSON.parse(require('fs').readFileSync('package.json','utf8'))"
  2. Look at the line/column number in the error and check for trailing commas or bad quotes
  3. If you recently merged branches, check for conflict markers: git diff package.json
  4. As a last resort, restore from git: git checkout HEAD -- package.json

Example

npm ERR! code EJSONPARSE npm ERR! Failed to parse JSON npm ERR! Note: package.json must be actual JSON, not just JavaScript. npm ERR! While parsing: /home/user/project/package.json:12:3

Adding a dependency to package.json manually and accidentally leaving a trailing comma

Have a different error?

Paste any error message into the Error Translator to get an instant explanation.