Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No token found and can't prompt for login when running with --non-interactive. #81

Closed
hallee9000 opened this issue Nov 4, 2019 · 21 comments
Labels
documentation Improvements or additions to documentation

Comments

@hallee9000
Copy link

hallee9000 commented Nov 4, 2019

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!

@clarkbw
Copy link

clarkbw commented Nov 6, 2019

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

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

@hallee9000
Copy link
Author

@clarkbw thanks, I'll try it.

@hallee9000
Copy link
Author

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

@D4nte
Copy link

D4nte commented Dec 3, 2019

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?

D4nte pushed a commit to comit-network/create-comit-app that referenced this issue Dec 3, 2019
D4nte pushed a commit to comit-network/create-comit-app that referenced this issue Dec 3, 2019
OndraM added a commit to lmc-eu/lmc-maps-js that referenced this issue Feb 4, 2020
OndraM added a commit to lmc-eu/lmc-maps-js that referenced this issue Feb 4, 2020
@ammmze
Copy link

ammmze commented Mar 28, 2020

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

@jorenbroekema
Copy link

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.

@chrvadala
Copy link

@jorenbroekema suggestion worked for me

gagbo added a commit to gagbo/goingnative that referenced this issue Jun 1, 2020
@bryanmacfarlane bryanmacfarlane added the documentation Improvements or additions to documentation label Jun 30, 2020
@bryanmacfarlane
Copy link
Member

Anything to doc or improve here? I see the link to help above and it sounds like it was enough.

@bitofbreeze
Copy link

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?

@jorenbroekema
Copy link

@CSFlorin few things you can try:
On line 28: change it to node-version: 12.x (adding the x)
On line 31: remove this entirely, setup-node action does it for you
On line 34: change it to NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} (so with spaces)

I suspect either the 2nd or the 1st suggestion will fix things for you. Don't think the third one matters but you could always try.

@bitofbreeze
Copy link

@jorenbroekema Thanks for the suggestions but I had already tried all these. See the workflow file for this run.

@jorenbroekema
Copy link

jorenbroekema commented Jul 7, 2020

@CSFlorin You didn't try the third suggestion in that run. I doubt it matters, but it potentially could, if they use use a replacer / template parser where the spaces are relevant. I'm not sure what else it could be :\

Also, are you sure you have a secret in that repository called NPM_TOKEN ? Because the error your action gives seems to indicate that it cannot find your NPM_TOKEN secret. Maybe check spelling, and to be sure, delete the existing one and remake it maybe.

@ndthanhdev
Copy link

ndthanhdev commented Sep 19, 2020

I use below steps for yarn2

      # ...
      - run: yarn config set npmPublishRegistry 'https://npm.pkg.github.com/'
      - shell: pwsh
        env:
          GH_REGISTRY_TOKEN: ${{ secrets.GH_REGISTRY_TOKEN }}
        run: yarn config set npmAuthToken "$env:GH_REGISTRY_TOKEN"
      - run: yarn workspaces foreach npm publish

@kumavis
Copy link

kumavis commented Sep 26, 2020

for yarn publish, adding always-auth: true to actions/setup-node@v1 solved it for me 👍

      uses: actions/setup-node@v1
      with:
        registry-url: 'https://registry.npmjs.org'
        node-version: ${{ matrix.node-version }}
        always-auth: true

@thecreazy
Copy link

thecreazy commented Jan 23, 2021

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

@BryanCrotaz
Copy link

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.

@echoulen
Copy link

echoulen commented Mar 14, 2021

NPM_AUTH_TOKEN work for npm registry
NODE_AUTH_TOKEN work for scope registry

Zemnmez added a commit to Zemnmez/do-sync that referenced this issue Aug 13, 2021
* try to fix publish issue vis-a-vis actions/setup-node#81
JohannesRudolph added a commit to meshcloud/notion-markdown-cms that referenced this issue Oct 30, 2021
@luxalpa
Copy link

luxalpa commented Nov 4, 2021

So is there any way to get this to work with Yarn v2? The solution from @ndthanhdev obviously uses Powershell, but I'm using ubuntu... And also it looks a bit hacky.

@dmitry-shibanov
Copy link
Contributor

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.

@brunofin
Copy link

brunofin commented Jul 17, 2022

@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!

chrisdrackett added a commit to tiltshift/config-archive that referenced this issue Aug 24, 2022
mantism added a commit to TrickingApi/tricking-ts that referenced this issue Jan 14, 2023
krzyk added a commit to krzyk/setup-node that referenced this issue Apr 11, 2023
SeriousBug added a commit to SeriousBug/live-limit that referenced this issue Apr 17, 2023
deining pushed a commit to deining/setup-node that referenced this issue Nov 9, 2023
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.0.2 to 4.0.5.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](microsoft/TypeScript@v4.0.2...v4.0.5)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Shaptic added a commit to stellar/js-xdr that referenced this issue Nov 20, 2023
Shaptic added a commit to stellar/js-xdr that referenced this issue Nov 20, 2023
@Anoiing
Copy link

Anoiing commented Jan 24, 2024

I encountered the same error and tried everyone's solution. The later error became that the token could not be found. After some inspection, I found that it was because a .npmrc file without a token field was written in the local project. I deleted the .npmrc file in the local project, and workflow could publish npm normally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests