NPM publish: SemanticReleaseError: Invalid npm token.

See original GitHub issue

Current behavior

Can’t publish with valid token using semantic-release. Running from local machine in dry run mode using:
GH_TOKEN=*** NPM_TOKEN=*** npx semantic-release.

Running npm publish with the same token works as expected.
npm version: 6.11.3 node version: v12.12.0

Expected behavior

Semantic-release should be able to publish to npm successfully.

Environment

  • semantic-release version: 15.13.27
  • CI environment: github actions
  • Plugins used:
"@semantic-release/commit-analyzer",
"@semantic-release/changelog",
"@semantic-release/github
"@semantic-release/npm",
@semantic-release/release-notes-generator
  • semantic-release configuration:
"release": {
    "branch": "master",
    "plugins": [
      "@semantic-release/commit-analyzer",
      "@semantic-release/changelog",
      "@semantic-release/github",
      [
        "@semantic-release/npm",
        {
          "pkgRoot": "dist/ng-select"
        }
      ],
      "@semantic-release/release-notes-generator"
    ]
  }
  • Logs running in dry mode on local machine:
[4:12:33 PM] [semantic-release] › ℹ  Running semantic-release version 15.13.27
[4:12:33 PM] [semantic-release] › ✔  Loaded plugin "verifyConditions" from "@semantic-release/changelog"
[4:12:33 PM] [semantic-release] › ✔  Loaded plugin "verifyConditions" from "@semantic-release/github"
[4:12:33 PM] [semantic-release] › ✔  Loaded plugin "verifyConditions" from "@semantic-release/npm"
[4:12:33 PM] [semantic-release] › ✔  Loaded plugin "analyzeCommits" from "@semantic-release/commit-analyzer"
[4:12:33 PM] [semantic-release] › ✔  Loaded plugin "generateNotes" from "@semantic-release/release-notes-generator"
[4:12:33 PM] [semantic-release] › ✔  Loaded plugin "prepare" from "@semantic-release/changelog"
[4:12:33 PM] [semantic-release] › ✔  Loaded plugin "prepare" from "@semantic-release/npm"
[4:12:33 PM] [semantic-release] › ✔  Loaded plugin "publish" from "@semantic-release/github"
[4:12:33 PM] [semantic-release] › ✔  Loaded plugin "publish" from "@semantic-release/npm"
[4:12:33 PM] [semantic-release] › ✔  Loaded plugin "success" from "@semantic-release/github"
[4:12:33 PM] [semantic-release] › ✔  Loaded plugin "fail" from "@semantic-release/github"
[4:12:33 PM] [semantic-release] › ⚠  This run was not triggered in a known CI environment, running in dry-run mode.
[4:12:33 PM] [semantic-release] › ⚠  Run automated release from branch master in dry-run mode
[4:12:37 PM] [semantic-release] › ✔  Allowed to push to the Git repository
[4:12:37 PM] [semantic-release] › ℹ  Start step "verifyConditions" of plugin "@semantic-release/changelog"
[4:12:37 PM] [semantic-release] › ✔  Completed step "verifyConditions" of plugin "@semantic-release/changelog"
[4:12:37 PM] [semantic-release] › ℹ  Start step "verifyConditions" of plugin "@semantic-release/github"
[4:12:37 PM] [semantic-release] [@semantic-release/github] › ℹ  Verify GitHub authentication
[4:12:37 PM] [semantic-release] › ✔  Completed step "verifyConditions" of plugin "@semantic-release/github"
[4:12:37 PM] [semantic-release] › ℹ  Start step "verifyConditions" of plugin "@semantic-release/npm"
[4:12:37 PM] [semantic-release] [@semantic-release/npm] › ℹ  Verify authentication for registry https://registry.npmjs.org/
https://registry.npmjs.org/
Error: Command failed with exit code 1 (EPERM): npm whoami --registry https://registry.npmjs.org/
    at makeError (/Users/tadeus/git/ng-select/node_modules/@semantic-release/npm/node_modules/execa/lib/error.js:59:11)
    at handlePromise (/Users/tadeus/git/ng-select/node_modules/@semantic-release/npm/node_modules/execa/index.js:112:26)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async module.exports (/Users/tadeus/git/ng-select/node_modules/@semantic-release/npm/lib/verify-auth.js:20:7)
    at async verifyConditions (/Users/tadeus/git/ng-select/node_modules/@semantic-release/npm/index.js:33:7)
    at async validator (/Users/tadeus/git/ng-select/node_modules/semantic-release/lib/plugins/normalize.js:34:24)
    at async /Users/tadeus/git/ng-select/node_modules/semantic-release/lib/plugins/pipeline.js:37:34
    at async /Users/tadeus/git/ng-select/node_modules/semantic-release/lib/plugins/pipeline.js:31:3
    at async Object.pluginsConf.<computed> [as verifyConditions] (/Users/tadeus/git/ng-select/node_modules/semantic-release/lib/plugins/index.js:80:11)
    at async run (/Users/tadeus/git/ng-select/node_modules/semantic-release/index.js:84:3) {
  command: 'npm whoami --registry https://registry.npmjs.org/',
  exitCode: 1,
  exitCodeName: 'EPERM',
  stdout: '',
  stderr: 'npm ERR! cb() never called!\n' +
    '\n' +
    'npm ERR! This is an error with npm itself. Please report this error at:\n' +
    'npm ERR!     <https://npm.community>\n' +
    '\n' +
    'npm ERR! A complete log of this run can be found in:\n' +
    'npm ERR!     /Users/tadeus/.npm/_logs/2019-11-01T14_12_39_078Z-debug.log',
  all: 'npm ERR! cb() never called!\n' +
    '\n' +
    'npm ERR! This is an error with npm itself. Please report this error at:\n' +
    'npm ERR!     <https://npm.community>\n' +
    '\n' +
    'npm ERR! A complete log of this run can be found in:\n' +
    'npm ERR!     /Users/tadeus/.npm/_logs/2019-11-01T14_12_39_078Z-debug.log',
  failed: true,
  timedOut: false,
  isCanceled: false,
  killed: false,
  signal: undefined
}
[4:12:39 PM] [semantic-release] › ✖  Failed step "verifyConditions" of plugin "@semantic-release/npm"
[4:12:39 PM] [semantic-release] › ⚠  Skip step "fail" of plugin "@semantic-release/github" in dry-run mode
[4:12:39 PM] [semantic-release] › ✖  EINVALIDNPMTOKEN Invalid npm token.
The npm token configured in the NPM_TOKEN environment variable must be a valid token allowing to publish to the registry https://registry.npmjs.org/.

If you are using Two-Factor Authentication, make configure the auth-only level is supported. semantic-release cannot publish with the default auth-and-writes level.

Please make sure to set the NPM_TOKEN environment variable in your CI with the exact value of the npm token.

AggregateError:
    SemanticReleaseError: Invalid npm token.
        at module.exports (/Users/tadeus/git/ng-select/node_modules/@semantic-release/npm/lib/get-error.js:6:10)
        at module.exports (/Users/tadeus/git/ng-select/node_modules/@semantic-release/npm/lib/verify-auth.js:23:33)
    at /Users/tadeus/git/ng-select/node_modules/semantic-release/lib/plugins/pipeline.js:54:11
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Object.pluginsConf.<computed> [as verifyConditions] (/Users/tadeus/git/ng-select/node_modules/semantic-release/lib/plugins/index.js:80:11)
    at async run (/Users/tadeus/git/ng-select/node_modules/semantic-release/index.js:84:3)
    at async module.exports (/Users/tadeus/git/ng-select/node_modules/semantic-release/index.js:170:22)
    at async module.exports (/Users/tadeus/git/ng-select/node_modules/semantic-release/cli.js:55:5) {
  name: 'AggregateError'
}%

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:6
  • Comments:25 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
pvdlgcommented, Nov 4, 2019

Maybe you had an outdate version with another bug due to your lockfile that is fixed now.

1reaction
pvdlgcommented, Nov 1, 2019

The @semantic-release/npm plugin check first if you have a ./.npmrc or a ~/.npmrc file with an an auth token, and you do it uses that one instead of the NPM_TOKEN environment variable.

Do you have either a ./.npmrc or a ~/.npmrc file in the environment that runs semantic-release? Please make sure you don’t have an outdated token there.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Gitlab semantic release not using private registry
For environment variables I have NPM_TOKEN , GL_TOKEN , GITLAB_TOKEN . Here is the actual error when running locally: >> @mygroup/npm_registry@ ...
Read more >
@semantic-release/npm - npm
semantic-release plugin to publish a npm package. Latest version: 9.0.1, last published: 10 months ago. Start using @semantic-release/npm in ...
Read more >
semantic-release/semantic-release - Gitter
{ SemanticReleaseError: The push permission to the Git repository is required. at ... AggregateError: SemanticReleaseError: Invalid npm token. [...].
Read more >
Learning to Use Semantic-Release the Hard Way
semantic-release is an NPM tool to automate the workflow to release an ... SemanticReleaseError: The maintenance branches are invalid in the ...
Read more >
@semantic-release/npm - npm Package Health Analysis | Snyk
semantic-release plugin to publish a npm package For more information about how to use this package see README · Ensure you're using the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found