GithubHelp home page GithubHelp logo

Comments (21)

hallee9000 avatar hallee9000 commented on August 23, 2024 22

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

from setup-node.

echoulen avatar echoulen commented on August 23, 2024 17

NPM_AUTH_TOKEN work for npm registry
NODE_AUTH_TOKEN work for scope registry

from setup-node.

jorenbroekema avatar jorenbroekema commented on August 23, 2024 11

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.

from setup-node.

thecreazy avatar thecreazy commented on August 23, 2024 10

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

from setup-node.

BryanCrotaz avatar BryanCrotaz commented on August 23, 2024 4

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.

from setup-node.

D4nte avatar D4nte commented on August 23, 2024 2

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?

from setup-node.

ammmze avatar ammmze commented on August 23, 2024 2
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

from setup-node.

bitofbreeze avatar bitofbreeze commented on August 23, 2024 1

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?

from setup-node.

dmitry-shibanov avatar dmitry-shibanov commented on August 23, 2024 1

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.

from setup-node.

brunofin avatar brunofin commented on August 23, 2024 1

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

from setup-node.

clarkbw avatar clarkbw commented on August 23, 2024

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

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

from setup-node.

hallee9000 avatar hallee9000 commented on August 23, 2024

@clarkbw thanks, I'll try it.

from setup-node.

chrvadala avatar chrvadala commented on August 23, 2024

@jorenbroekema suggestion worked for me

from setup-node.

bryanmacfarlane avatar bryanmacfarlane commented on August 23, 2024

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

from setup-node.

jorenbroekema avatar jorenbroekema commented on August 23, 2024

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

from setup-node.

bitofbreeze avatar bitofbreeze commented on August 23, 2024

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

from setup-node.

jorenbroekema avatar jorenbroekema commented on August 23, 2024

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

from setup-node.

ndthanhdev avatar ndthanhdev commented on August 23, 2024

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

from setup-node.

kumavis avatar kumavis commented on August 23, 2024

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

from setup-node.

luxalpa avatar luxalpa commented on August 23, 2024

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.

from setup-node.

Anoiing avatar Anoiing commented on August 23, 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.

from setup-node.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.