How to fix npm ERR! code E402 npm ERR! 402 Payment Required - This package requires a paid npm subscription in npm

npmBEGINNERMEDIUMUpdated Dec 5, 2025ยท 132 views

The E402 'Payment Required' error occurs when trying to publish or install scoped packages without proper access configuration or when an npm organization's billing is unpaid. Scoped packages default to private and require either a paid npm subscription or explicit public access declaration.

Quick fix

Fixes npm ERR! code E402 npm ERR! 402 Payment Required - This package requires a paid npm subscription

npm publish --access=public
  1. For public scoped packages, use the --access=public flag
  2. Add publishConfig to package.json for permanent public access
  3. Verify npm organization account has active paid subscription
  4. Check authentication token permissions for private packages
npm โ€” error
npm publish --access=public
npm ERR! code E402
npm ERR! 402 Payment Required - This package requires a paid npm subscription

What this error means

npm's E402 error indicates that the registry (npmjs.org) has rejected your request with an HTTP 402 Payment Required status. This typically happens in two scenarios: (1) You're attempting to publish a scoped package (like @org/package-name) without declaring it as public, and scoped packages are private by default, requiring a paid npm organization subscription. (2) Your npm organization has an unpaid or expired billing account, preventing access to private packages. The HTTP 402 status code is a standard web error meaning the server requires payment to fulfill the request. In npm's case, this gates access to premium features like private packages and organizations.

Typical symptoms

  • Publishing fails with 'npm ERR! code E402 402 Payment Required'
  • Installing private packages from your organization fails with 402 error
  • Error message includes 'You must sign up for private packages'
  • Scoped package publish attempts fail even though you own the scope
  • CI/CD pipelines fail when attempting to install or publish organizational packages

Common causes

  1. Attempting to publish a scoped package without declaring it as public (scoped packages default to private)
  2. npm organization account has unpaid or expired billing
  3. Publishing a new scoped package without the --access=public flag on first publish
  4. Using a scoped package name without having a valid npm organization account
  5. Authentication token lacks permission to publish or install private packages

How to fix "npm ERR! code E402 npm ERR! 402 Payment Required - This package requires a paid npm subscription"

1For public scoped packages, use the --access=public flag

If your scoped package should be public, the most direct fix is to include the --access flag when publishing:

bash
npm publish --access=public

This tells npm registry that despite the package being scoped, it should be publicly available.

2Add publishConfig to package.json for permanent public access

To avoid needing the flag every time, configure your package.json to default to public:

json
{
  "name": "@your-scope/package-name",
  "version": "1.0.0",
  "publishConfig": {
    "access": "public"
  }
}

This ensures that all future publishes default to public access without requiring the CLI flag.

3Verify npm organization account has active paid subscription

If you're installing private packages or have a legitimate need for private scope packages, verify your npm organization account has active billing:

1. Go to https://www.npmjs.com/settings/your-org/billing
2. Check that your subscription is active and payment method is valid
3. Update billing information if needed
4. Run npm install again after confirming billing is active

4Check authentication token permissions for private packages

If you're attempting to install private packages in CI/CD, ensure your authentication token has the correct permissions:

bash
npm whoami

# For CI/CD, set the token in .npmrc
echo "//registry.npmjs.org/:_authToken=YOUR_TOKEN_HERE" >> ~/.npmrc

Make sure the token has read-write access for private packages, not just read-only access.

5Remove scope if you don't have organization account

If you don't need to use a scoped package name and don't have an npm organization account, rename your package to remove the scope:

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

Unscoped packages are public by default. Rename your package to reflect this change, and publish without the scope prefix.

Advanced notes

Understanding npm's pricing model is crucial: Individual npm accounts with the default free tier can publish public, unscoped packages freely. However, scoped packages (@scope/name) default to private regardless of account type and require npm Teams (paid organization account) or a paid private package subscription. When using monorepos with tools like Lerna or Nx, ensure each scoped package in the publishConfig includes 'access: public' if those packages should be publicly available. For CI/CD environments installing private packages, use granular access tokens with read-only permissions when possible.

Frequently asked questions

What does "npm ERR! code E402 npm ERR! 402 Payment Required - This package requir" mean?
org) has rejected your request with an HTTP 402 Payment Required status. This typically happens in two scenarios: (1) You're attempting to publish a scoped package (like @org/package-name) without declaring it as public, and scoped packages are private by default, requiring a paid npm organization subscription. (2) Your npm organization has an unpaid or expired billing account, preventing access to private packages.
How do I fix "npm ERR! code E402 npm ERR! 402 Payment Required - This package requir"?
The E402 'Payment Required' error occurs when trying to publish or install scoped packages without proper access configuration or when an npm organization's billing is unpaid. Scoped packages default to private and require either a paid npm subscription or explicit public access declaration.
What causes "npm ERR! code E402 npm ERR! 402 Payment Required - This package requir"?
Attempting to publish a scoped package without declaring it as public (scoped packages default to private) npm organization account has unpaid or expired billing Publishing a new scoped package without the --access=public flag on first publish
Is the "npm ERR! code E402 npm ERR! 402 Payment Required - This package requir" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading