How to fix npm ERR! code EPRIVATE npm ERR! This package has been marked as private in npm

npmBEGINNERMEDIUMUpdated Dec 5, 2025· 206 views

The EPRIVATE error occurs when you attempt to publish a package that has "private": true in its package.json. This field is a safeguard that prevents npm from publishing the package at all, regardless of destination registry.

Quick fix

Fixes npm ERR! code EPRIVATE npm ERR! This package has been marked as private

{
  "name": "my-package",
  "version": "1.0.0",
  "private": true
}
  1. Remove the private field from package.json
  2. For scoped packages, use --access flag if needed
  3. For private registries, configure .npmrc
  4. For monorepos, only remove private from publishable packages
npm — error
{
"name": "my-package",
"version": "1.0.0",
"private": true
}
npm ERR! code EPRIVATE
npm ERR! This package has been marked as private

What this error means

The "npm ERR! code EPRIVATE" error occurs when you attempt to publish a package to the npm registry, but the package.json file contains "private": true. This field is a safeguard that prevents npm from publishing the package at all, regardless of destination registry. The "private" field is specifically designed to block publication entirely—it's not a mechanism for creating "private packages" in the sense of restricted access. If you want to publish packages with restricted access, you must remove this field and instead use npm's paid private package features or a private registry. This is npm working as designed, protecting you from accidentally publishing internal code.

Typical symptoms

  • npm publish command fails immediately with error code EPRIVATE
  • Error message states 'This package has been marked as private'
  • npm suggests 'Remove the private field from the package.json to publish it'
  • No package is published despite running npm publish
  • In monorepos, some workspace packages won't publish due to private marking

Common causes

  1. package.json contains "private": true which explicitly prevents all publishing
  2. Accidentally copied package.json from a private project or template
  3. Monorepo root package.json has private: true (intentional for root)
  4. Intentionally set private: true to prevent accidental publication

How to fix "npm ERR! code EPRIVATE npm ERR! This package has been marked as private"

1Remove the private field from package.json

Edit your package.json and delete the line containing "private": true:

Before:

json
{
  "name": "my-package",
  "version": "1.0.0",
  "private": true
}

After:

json
{
  "name": "my-package",
  "version": "1.0.0"
}

Then run: npm publish

2For scoped packages, use --access flag if needed

If publishing an organization-scoped package (@myorg/package-name):

1. Remove "private": true from package.json
2. Ensure your package.json name uses the scope:

json
{ "name": "@myorg/my-package" }

3. Publish with appropriate access level:
- For private (requires paid account): npm publish
- For public: npm publish --access public

3For private registries, configure .npmrc

If you want to publish to a private registry (GitHub Packages, Verdaccio, Artifactory):

1. Remove "private": true from package.json
2. Create or edit .npmrc with the appropriate registry:

Example for GitHub Packages:

bash
//npm.pkg.github.com/:_authToken=YOUR_GITHUB_TOKEN
@yourorg:registry=https://npm.pkg.github.com/

3. Publish: npm publish

4For monorepos, only remove private from publishable packages

In a monorepo with workspaces:

1. Keep "private": true in the root package.json (prevents accidental root publication)
2. Remove "private": true from workspace packages that should be published

json
// Root package.json (keep private)
{ "private": true, "workspaces": ["packages/*"] }

// packages/my-lib/package.json (remove private)
{ "name": "@myorg/my-lib", "version": "1.0.0" }

Publish individual workspaces:

bash
npm publish --workspace=packages/my-lib
5Use npm Private Packages or GitHub Packages for restricted access

If you want restricted access (not blocking publication):

npm Private Packages (paid):
- Requires paid npm account
- Only scoped packages can be private
- Publish with: npm publish

GitHub Packages (free):
- Free, no paid npm account required
- Configure .npmrc with GitHub token
- Collaborators need GitHub access to install

Remove "private": true and use registry access controls instead.

Advanced notes

Understanding the distinction:
The npm ecosystem uses "private" in two different ways:
1. package.json "private" field = "Do not publish this package anywhere" (a safeguard)
2. "Private packages" on npmjs.com = "Published packages with restricted access" (requires paid account)

These are fundamentally different concepts.

Why this safeguard exists: The "private" field was added to prevent accidents. Developers often clone repositories or run npm commands in the wrong terminal. Without this safeguard, internal code could be accidentally published to the public registry.

Common monorepo patterns: It's standard to mark the root package.json as private while individual workspace packages are publishable.

Scoped package naming: When publishing privately, always use scoped names (@myorg/internal-package). Scoped packages default to private when published with a paid account.

Frequently asked questions

What does "npm ERR! code EPRIVATE npm ERR! This package has been marked as privat" mean?
The "npm ERR! json file contains "private": true. This field is a safeguard that prevents npm from publishing the package at all, regardless of destination registry.
How do I fix "npm ERR! code EPRIVATE npm ERR! This package has been marked as privat"?
The EPRIVATE error occurs when you attempt to publish a package that has "private": true in its package.json. This field is a safeguard that prevents npm from publishing the package at all, regardless of destination registry.
What causes "npm ERR! code EPRIVATE npm ERR! This package has been marked as privat"?
package.json contains "private": true which explicitly prevents all publishing Accidentally copied package.json from a private project or template Monorepo root package.json has private: true (intentional for root)
Is the "npm ERR! code EPRIVATE npm ERR! This package has been marked as privat" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading