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

Auth tokens configured by pnpm config set are not found by npm #6181

Closed
zkochan opened this issue Mar 5, 2023 · 3 comments · Fixed by #6195
Closed

Auth tokens configured by pnpm config set are not found by npm #6181

zkochan opened this issue Mar 5, 2023 · 3 comments · Fixed by #6195
Milestone

Comments

@zkochan
Copy link
Member

zkochan commented Mar 5, 2023

The version 7.28.0 doesn't work, but the 7.27.1 works. Here's the relevant part of the config to make it work:

publish:
  stage: publish
  before_script:
    - corepack enable
    - corepack prepare pnpm@7.27.1 --activate
    - pnpm config set "//${GITLAB_REGISTRY}:_authToken=${CI_JOB_TOKEN}"

Originally posted by @navaru in #4937 (comment)

This happens because pnpm config set writes to its own rc file at ~/.config/pnpm/rc, which is not read by npm CLI (and pnpm publish run npm publish under the hood).

I think the solution should be to make pnpm run npm config set when auth tokens are configured.

@semiautomatix
Copy link

gitlab-ci.yml

image: node:latest

stages:
  - deploy

deploy:
  stage: deploy
  before_script:
    - corepack enable
    - corepack prepare pnpm@latest --activate
    - npm config set "//${CI_SERVER_HOST}/api/v4/projects/${CI_PROJECT_ID}/packages/npm/:_authToken=${CI_JOB_TOKEN}"
  script:
    - pnpm install --frozen-lockfile --strict-peer-dependencies
    - pnpm publish --publish-branch main --no-git-checks

I thought I'd double-check this doesn't work. No luck, I'm afraid.

npm ERR! code ENEEDAUTH
npm ERR! need auth This command requires you to be logged in to https://gitlab.com/api/v4/projects/43729055/packages/npm/
npm ERR! need auth You need to authorize this machine using `npm adduser`
npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2023-03-08T00_50_37_922Z-debug-0.log

@zkochan
Copy link
Member Author

zkochan commented Mar 8, 2023

@semiautomatix you issue is probably the same as this: #5616

@semiautomatix
Copy link

@semiautomatix you issue is probably the same as this: #5616

Appreciate the link. Seems npm config set isn't appending to the .npmrc file. I've had to echo >>.pnprc for a result.

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

Successfully merging a pull request may close this issue.

2 participants