How to fix npm ERR! This package has been marked as private in npm
The EPRIVATE error occurs when attempting to publish a package that has "private": true in package.json. This is a safety feature to prevent accidental publication of internal code.
Quick fix
Fixes npm ERR! This package has been marked as private
{
"name": "my-package",
"version": "1.0.0",
"private": false
}- Remove or disable the private field
- Use --access public for scoped packages
- Add publishConfig to package.json
- Verify authentication
{"name": "my-package","version": "1.0.0","private": false}npm ERR! This package has been marked as private
What this error means
The EPRIVATE error is npm's safeguard against accidentally publishing private or internal packages to the public registry. When package.json contains `"private": true`, npm refuses to publish the package to any registry. This is distinct from npm's paid private packages feature. The `private` field in package.json means "never publish this package anywhere"—it's commonly used for application repositories, internal tools, and monorepo root packages that should never be distributed as npm packages.
Typical symptoms
- npm publish fails with EPRIVATE error code
- Error message says "Remove the private field from package.json to publish it"
- CI/CD pipelines fail during automated package releases
- Scoped packages fail even without explicit private field
- Publishing to private registries also blocked
- Confusion between npm private and GitHub private repositories
Common causes
- "private": true explicitly set in package.json
- Scoped packages default to restricted access without --access public
- Package was never intended to be published (application code)
- Monorepo root package mistakenly being published instead of sub-package
- Missing publishConfig.access setting for scoped packages
- Copied package.json from private project without removing private field
How to fix "npm ERR! This package has been marked as private"
Edit package.json to remove the private restriction:
{
"name": "my-package",
"version": "1.0.0",
"private": false
}Or simply remove the "private" field entirely—packages are public by default.
Scoped packages (@username/package) default to restricted. Make them public explicitly:
# Publish scoped package as public
npm publish --access publicThis is required even if the private field is not set.
Persist the access setting for future publishes:
{
"name": "@myorg/my-package",
"version": "1.0.0",
"publishConfig": {
"access": "public"
}
}This eliminates the need to pass --access public every time.
Ensure you're logged in with proper permissions:
# Check current login
npm whoami
# Re-authenticate if needed
npm logout
npm login
# Verify email is confirmed
npm profile getIn monorepos, ensure you're in the correct directory:
# Check current package name
cat package.json | grep '"name"'
# Navigate to correct package directory
cd packages/my-publishable-package
npm publishThe root package.json often has private: true intentionally.
If publishing to a private registry (not npm public), configure the registry:
{
"name": "@myorg/my-package",
"publishConfig": {
"registry": "https://npm.pkg.github.com"
}
}Note: The private: true field still blocks publishing to ANY registry, including private ones.
Advanced notes
The private field serves different purposes in different contexts. For application repositories (websites, APIs, CLI tools that aren't distributed via npm), setting "private": true is a best practice that prevents accidental publication.
For monorepos, the root package.json should have "private": true while publishable sub-packages should not. Tools like Lerna and Turborepo handle this automatically.
In CI/CD, always include --access public in publish commands for scoped packages, or use publishConfig in package.json. Environment variable NPM_TOKEN must have publish permissions for the scope.
Frequently asked questions
- What does "npm ERR! This package has been marked as private" mean?
- The EPRIVATE error is npm's safeguard against accidentally publishing private or internal packages to the public registry. json contains "private": true, npm refuses to publish the package to any registry. This is distinct from npm's paid private packages feature.
- How do I fix "npm ERR! This package has been marked as private"?
- The EPRIVATE error occurs when attempting to publish a package that has "private": true in package.json. This is a safety feature to prevent accidental publication of internal code.
- What causes "npm ERR! This package has been marked as private"?
- "private": true explicitly set in package.json Scoped packages default to restricted access without --access public Package was never intended to be published (application code)
- Is the "npm ERR! This package has been marked as private" error serious?
- It is a low-severity error — more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- 📚npm Official Documentation
- 💬Stack Overflow: npm err this package has been marked as private(Stack Overflow)
- 🔗
- 🐙GitHub #3010: npm/cli(GitHub)