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

pnpm publish doesn't work with tokenHelper #7316

Closed
2 of 4 tasks
ari-becker opened this issue Nov 15, 2023 · 1 comment · Fixed by #7443
Closed
2 of 4 tasks

pnpm publish doesn't work with tokenHelper #7316

ari-becker opened this issue Nov 15, 2023 · 1 comment · Fixed by #7443

Comments

@ari-becker
Copy link

ari-becker commented Nov 15, 2023

Verify latest release

  • I verified that the issue exists in the latest pnpm release

pnpm version

No response

Which area(s) of pnpm are affected? (leave empty if unsure)

No response

Link to the code that reproduces this issue or a replay of the bug

No response

Reproduction steps

  1. Set up a token for publishing using tokenHelper, i.e. a ~/.npmrc with:
//npm.pkg.github.com/:tokenHelper=/Users/ari/.local/bin/gh-token-helper

where the contents of that file are:

#! /bin/sh

/opt/homebrew/bin/gh auth token
  1. Attempt to publish a package to GitHub Packages via pnpm publish

Describe the Bug

Running pnpm publish results in the following error:

npm ERR! code ENEEDAUTH
npm ERR! need auth This command requires you to be logged in to https://npm.pkg.github.com/
npm ERR! need auth You need to authorize this machine using `npm adduser`

This happens because npm does not support tokenHelper, and pnpm passes through publish to npm instead of natively implementing it.

Expected Behavior

Successful publish, or at least an error message saying that tokenHelper is not supported while publishing.

Workaround is to run the tokenHelper to procure a token and then paste it into ~/.npmrc in the _authToken field, which is supported by npm.

Which Node.js version are you using?

20.9.0

Which operating systems have you used?

  • macOS
  • Windows
  • Linux

If your OS is a Linux based, which one it is? (Include the version if relevant)

No response

@Shinyaigeek
Copy link
Member

gh auth token command will output token, but it does not include Beader prefix. This issue seems to be happen because of this lack of Beader prefix. You may be able to fix this issue by fixing your /Users/ari/.local/bin/gh-token-helper like below.

echo "Bearer $(/opt/homebrew/bin/gh auth token)"

@nachoaldamav nachoaldamav self-assigned this Dec 19, 2023
zkochan added a commit that referenced this issue Jan 8, 2024
Close #7316

---------

Co-authored-by: Zoltan Kochan <z@kochan.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants