How to fix npm ERR! code EPARSE npm ERR! Error parsing configuration in npm

npmBEGINNERHIGHUpdated Dec 3, 2025· 150 views

The npm EPARSE error occurs when npm fails to parse a configuration file (package.json or .npmrc), typically due to invalid JSON syntax, malformed key-value pairs, or file encoding issues. This error prevents package installation and other npm operations.

Quick fix

Fixes EPARSE

{
  "name": "my-app",
  "dependencies": {
    "express": "^4.18.0",
  }
}
  1. Validate your package.json syntax
  2. Check your .npmrc file for syntax errors
  3. Fix file encoding issues
  4. Remove and regenerate package-lock.json
npm — error
{
"name": "my-app",
"dependencies": {
"express": "^4.18.0",
}
}
npm ERR! code EPARSE
npm ERR! Error parsing configuration

What this error means

npm encountered a syntax error while trying to read and interpret one of its configuration files. This can happen in package.json (JSON syntax error) or in .npmrc files (ini-format syntax error). When npm parses these files, it expects strict formatting—any deviation causes it to throw the EPARSE code.

Typical symptoms

  • npm install or npm commands fail with 'npm ERR! code EPARSE Error parsing configuration'
  • npm error message indicates the specific file that failed to parse
  • Commas appear in unexpected places or are missing from JSON
  • .npmrc file contains malformed registry or authentication configurations
  • Error appears after editing package.json or .npmrc manually

Common causes

  1. Trailing commas in package.json after the last dependency, script, or property
  2. Missing commas between JSON key-value pairs in package.json
  3. Syntax errors in .npmrc file (incorrect key=value format)
  4. Invalid JSON in package.json (unclosed braces, quotes, or brackets)
  5. .npmrc file uses wrong syntax, such as @scope=url instead of @scope:registry=url
  6. File encoding issues (UTF-16 instead of UTF-8)
  7. Comments in JSON files (JSON does not support comments)

How to fix "npm ERR! code EPARSE npm ERR! Error parsing configuration"

1Validate your package.json syntax

Open your package.json file and validate it using jsonlint.com or similar.

Example of invalid syntax (trailing comma):

json
{
  "name": "my-app",
  "dependencies": {
    "express": "^4.18.0",
  }
}

Correct syntax:

json
{
  "name": "my-app",
  "dependencies": {
    "express": "^4.18.0"
  }
}
2Check your .npmrc file for syntax errors

If you have a .npmrc file, verify its syntax (ini-format, not JSON):

Correct .npmrc syntax:

bash
@my-org:registry=https://npm.pkg.github.com/
//npm.pkg.github.com/:_authToken=YOUR_TOKEN
registry=https://registry.npmjs.org/

Common mistakes:
- Using @scope=url instead of @scope:registry=url
- Using registry.com:authToken instead of //registry.com/:_authToken

3Fix file encoding issues

Ensure the file is saved as UTF-8, not UTF-16.

In VS Code:
1. Open the file
2. Click the encoding selector in the bottom-right corner
3. Select "UTF-8"
4. Save the file

4Remove and regenerate package-lock.json

A corrupted package-lock.json can also cause parsing errors:

bash
rm package-lock.json
npm install
5Clear npm cache

Clear the npm cache to remove any cached corrupt configuration:

bash
npm cache clean --force
6Configure npm using the command line

Instead of manually editing .npmrc, use npm config:

bash
npm config set registry https://registry.npmjs.org/
npm config set //npm.pkg.github.com/:_authToken=YOUR_TOKEN

Verify your configuration:

bash
npm config list

Advanced notes

The EPARSE error can originate from multiple sources: package.json uses strict JSON parsing; .npmrc uses ini-format parsing with different rules. npm loads config from multiple files in order: ~/.npmrc, .npmrc in the project root, and ~/.npm/node-gyp/.npmrc, and the first parse error in any causes the failure.

Frequently asked questions

What does "EPARSE" mean?
npm encountered a syntax error while trying to read and interpret one of its configuration files. npmrc files (ini-format syntax error). When npm parses these files, it expects strict formatting—any deviation causes it to throw the EPARSE code.
How do I fix "EPARSE"?
The npm EPARSE error occurs when npm fails to parse a configuration file (package.json or .npmrc), typically due to invalid JSON syntax, malformed key-value pairs, or file encoding issues. This error prevents package installation and other npm operations.
What causes "EPARSE"?
Trailing commas in package.json after the last dependency, script, or property Missing commas between JSON key-value pairs in package.json Syntax errors in .npmrc file (incorrect key=value format)
Is the "EPARSE" error serious?
Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.

Official resources & further reading