Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there some problem using pnpm with github packages?

Tags:

pnpm

My ~/.npmrc looks like

% cat ~/.npmrc
//npm.pkg.github.com/:_authToken=XXXXXXX
//npmjs.org=true
@1uphealth:registry=https://npm.pkg.github.com/1uphealth

In theory our packages like @1uphealth/foobar get installed from our private github packages repository and this works fine for npm

It seems to match the pnpm docs, here, https://pnpm.io/npmrc#url_authtoken, too.

But I am getting this error,

 ERR_PNPM_FETCH_401  GET https://npm.pkg.github.com/1uphealth/@1uphealth%2Fcore-1upenv-script: Unauthorized - 401

No authorization header was set for the request.

These authorization settings were found:
//npm.pkg.github.com/:_authToken=[hidden]
@1uphealth:registry=https://npm.pkg.github.com/1uphealth
like image 492
Marvin Avatar asked Oct 22 '25 05:10

Marvin


1 Answers

It seems like the problem is appending the owner to the registry url.

❌ Wrong

@1uphealth:registry=https://npm.pkg.github.com/1uphealth

✅ Correct

@1uphealth:registry=https://npm.pkg.github.com

✅ Full Working Example

# Use github package registry for @owner-co namespace
# Enables respective namespaces packages to pull from GitHub Packages Registry
@owner-co:registry=https://npm.pkg.github.com
# Enables accessing private GitHub Packages
# Token must have read:packages permission
# GitHub Tokens - https://github.com/settings/tokens
//npm.pkg.github.com/:_authToken=ghp_ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ

Source - https://github.com/pnpm/pnpm/issues/2933#issuecomment-975886322

like image 170
Sam Carlton Avatar answered Oct 27 '25 06:10

Sam Carlton