Comments (21)
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.
NPM_AUTH_TOKEN
work for npm registry
NODE_AUTH_TOKEN
work for scope registry
from setup-node.
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.
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.
sorry for the questions if is stupid, but why the env in all the example is called
NODE_AUTH_TOKEN
and noNPM_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.
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.
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.
from setup-node.
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:
And here is the action file. Anyone have an idea?
from setup-node.
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.
@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.
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.
@clarkbw thanks, I'll try it.
from setup-node.
@jorenbroekema suggestion worked for me
from setup-node.
Anything to doc or improve here? I see the link to help above and it sounds like it was enough.
from setup-node.
@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.
@jorenbroekema Thanks for the suggestions but I had already tried all these. See the workflow file for this run.
from setup-node.
@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.
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.
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.
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.
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)
- Support env setting of AGENT_TOOLSDIRECTORY as in the setup-python action HOT 2
- Bug reports HOT 1
- Following the installation instructions does not work HOT 3
- 404 when trying to publish to npm. HOT 5
- "Path Validation Error" in post-step HOT 1
- Yarn not installed on new arm64 runners HOT 1
- Cannot install package manager using corepack on node 16 HOT 5
- .npmrc auth content will be ignored when I supply a .npmrc file local HOT 5
- Small error on the README HOT 4
- docs: Node version file: Clarify effect of version range in engines.node HOT 1
- EACCES: permission denied HOT 11
- Hacked
- npm ci hangs in workflow for certain versions of node HOT 7
- lssue HOT 1
- Changing node-version without changing action makes merging impossible (required job pending) HOT 2
- Unable to publish to Github unless I append username to front HOT 7
- Regression in Node 22.5.0 fixed in 22.5.1 HOT 4
- Issue with Saving Yarn Cache on Self-Hosted Runner HOT 1
- Since nvm v0.40.0 .nvmrc may contain comments HOT 5
- Add fallback cache keys HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from setup-node.