setup-node: No token found and can't prompt for login when running with --non-interactive.

In my repo I have the workflow like this:

- run: yarn publish
  env:
    NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

I’ve added NPM_AUTH_TOKEN to secrets, but got this error:

image

Run yarn publish
  yarn publish
  shell: /bin/bash -e {0}
  env:
    NODE_AUTH_TOKEN: ***
yarn publish v1.19.1
[1/4] Bumping version...
info Current version: 0.1.22
[2/4] Logging in...
error No token found and can't prompt for login when running with --non-interactive.
info Visit https://yarnpkg.com/en/docs/cli/publish for documentation about this command.
##[error]Process completed with exit code 1.

I have tried many times and can’t figure it out. My repo is https://github.com/leadream/juuust-icon. Can anyone help me? Thanks!

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 19
  • Comments: 21 (2 by maintainers)

Commits related to this issue

Most upvoted comments

Yarn requires always-auth to authorize, NPM tends to ignore this. Add it like this:

      - uses: actions/setup-node@v1
        with:
          always-auth: true

Still don’t work for me, but adding this line in below works.

- run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_AUTH_TOKEN }}" > ~/.npmrc

NPM_AUTH_TOKEN work for npm registry NODE_AUTH_TOKEN work for scope registry

For me I just need to supply the following:

steps:
    - uses: actions/checkout@v2
    - name: Publish new version to NPM
      uses: actions/setup-node@v1
      with:
        node-version: 13.x
        registry-url: 'https://registry.npmjs.org'
    - run: yarn publish
      env:
        NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

https://help.github.com/en/actions/language-and-framework-guides/publishing-nodejs-packages

This sets the always-auth automatically, as well as the registry and scope etc.

sorry for the questions if is stupid, but why the env in all the example is called NODE_AUTH_TOKEN and no NPM_AUTH_TOKEN ?

I use NPM_AUTH_TOKEN and works good for me

sorry for the questions if is stupid, but why the env in all the example is called NODE_AUTH_TOKEN and no NPM_AUTH_TOKEN ?

I use NPM_AUTH_TOKEN and works good for me

OMG thank you - I’ve been trying every example I can find and getting nowhere. Tried NPM_AUTH_TOKEN instead and boom. Success.

echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_AUTH_TOKEN }}" > ~/.npmrc

You may wanna check your the log in the actions to ensure the token isn’t getting logged in there. I’m not sure if github scrubs secrets from the log output or not. If they are scrubbing the output, then it should be all good. I didn’t feel like testing it out.

I brought it in as an environment variable so it is evaluated in the shell rather than before sending to the shell.

- name: Publish
  run: echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > ~/.npmrc && yarn publish
  env:
    NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

And the result is the logged output just shows the name of the environment variable. sync-pom-version-to-package@859fa53 2020-03-28 10-40-31

Hi,

I have the same issue. One repo it works: https://github.com/comit-network/comit-js-sdk/ but then the same config does not work on a different repo: https://github.com/comit-network/create-comit-app/pull/243/checks?check_run_id=330403347

Is the solution above the official one or should we follow up with yarn to fix it?

@CSFlorin thanks for posting a link to your file, I figured by now you could have solved the problem, I copied your publish steps and it just works, so thanks!

Hello everyone. I’m going to close the issue, because the documentation was updated after releasing tag v2. If you have any concerns feel free to create a separate issue or pull request with updating documentation.

Hello @luxalpa. Actually you can use @ndthanhdev solution with bash, because this solution does not involve any powershell specific commands.

I’ve tried all the solutions above and none seems to work for me. Here are the various runs. And I have my npm token: image

And here is the action file. Anyone have an idea?