Description
Description:
Workflow scope not being detected / defaults to npm when attempting to upload to both npmjs.com and Github.
Action version:
v4
Platform:
- Ubuntu
- macOS
- Windows
Runner type:
- Hosted
- Self-hosted
Tools version:
- node: v20.15.0
- npm: 10.7.0
Repro steps:
- Set up a worker for pushing to both Github and npmjs (see below)
Expected behavior:
Worker should publish to both npmjs and github with the same workflow.
Actual behavior:
Created a single github workflow, it publishes to Github and npmjs
- name: "⚙️ Setup Node"
id: task_gpr_node_setup
uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: https://npm.pkg.github.com/
scope: '@aetherinox'
In the example above, I've provided the scope
, as well as the Github npm repo. However, when actually running the workflow, I get:
npm error need auth This command requires you to be logged in to https://registry.npmjs.org/
npm error need auth You need to authorize this machine using `npm adduser`
npm error A complete log of this run can be found in: /home/runner/.npm/_logs/2024-07-11T08_50_52_693Z-debug-0.log
What I've noticed is that I can get Github to successfully publish my package, but I must modify my package name itself. If I change the package name to:
"name": "@aetherinox/node-toasted",
It works fine, however, if I use
"name": "node-toasted",
I get the error listed above. And after searching this git repo issue section; I've noticed quite a few are getting it, but no definitive solution. I've ensured my tokens are right, and they are. As soon as I switch the package name to include @username, then it publishes fine.
Obviously this could be a solution, but I'd prefer my packages don't start with my username on npmjs, otherwise it makes searching more complicated.
I was assuming scope
is what would allow for a package name, without the need for the username at the beginning.
Here is one of the failed runs:
And here is the successful run:
For now I've removed the npmjs publish code until I can figure out how to publish to github without the name being appended to the front.
Here is the workflow file:
A little messy with now until I get this figured out.
I did however, review the logs from the workflow, and saw this, which doesn't make sense. If it's seeing that scope, why the package name change:
Run actions/setup-node@v4
with:
node-version: 20.x
registry-url: https://npm.pkg.github.com/
scope: aetherinox
always-auth: false
check-latest: false
token: ***
Also tried both scopes:
scope: @aetherinox
scope: aetherinox
And I tried printing /home/runner/work/_temp/.npmrc
:
//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}
@aetherinox:registry=https://npm.pkg.github.com/
always-auth=false
Been reading around, and someone posted using
npm init -y --scope 'scope name'
during the build process, however, it seems to cut off part of the name
name: 'node-toasted'
becomes name: '@aetherinox/toasted'