-
-
Notifications
You must be signed in to change notification settings - Fork 940
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
401 Unauthorized, installing package from private Github npm registry. #2687
Comments
I just updated to v5.4.0, the issue still persists. |
Could you try to set the auth token like this?
|
That yields the same error. |
I was facing a similar issue. Two things I observed-
|
@milind009 That's expected, according to Visual Studio docs. See https://docs.microsoft.com/en-us/azure/devops/artifacts/npm/scopes?view=azure-devops&tabs=windows |
@zkochan This might help - I set up a dumb server, that logs the request headers. These are the headers
And these are what NPM sets, on the initial request:
|
Here's the code that is getting the auth information from Maybe pnpm doesn't find the global |
I'm pretty sure that pnpm sees the I just tried putting the auth config, in my project root- I'm curious to know, what you did exactly. Something must be different. |
maybe you could try to debug https://github.com/pnpm/credentials-by-uri to see why the auth token from the settings is not used by pnpm |
Due to lack of the documentation, there is no way the I have setup a example based on const credentialsByUri = require('credentials-by-uri');
const config = {
"//npm.pkg.github.com/:_authToken": "{PERSONAL_ACCESS_TOKEN}",
"//npm.pkg.github.com/:always-auth": "false"
};
return credentialsByUri(config, "https://npm.pkg.github.com"); And it throws an error. |
The registry option should be always set: https://runkit.com/zkochan/5f1e8c8fd2a7f4001a8e9665 |
I can get private github package registry working in my project. .npmrc in root project
Then follow the instruction in github package detail page, but using pnpm
But, it only works if the package never installed before. When I delete
Here is the .pnpm-debug.log "7485 debug pnpm:request-retry": {
"attempt": 2,
"error": {
"code": "ERR_PNPM_TARBALL_FETCH",
"httpStatusCode": 401,
"uri": "https://npm.pkg.github.com/download/{SCOPE}/{PACKAGE}/{VERSION}/{SOME_RANDOM_STRING}",
"response": {
"size": 0,
"timeout": 0
},
"attempts": 2,
"resource": "https://npm.pkg.github.com/download/{SCOPE}/{PACKAGE}/{VERSION}/{SOME_RANDOM_STRING}"
},
"maxRetries": 2,
"method": "GET",
"timeout": 60000,
"url": "https://npm.pkg.github.com/download/{SCOPE}/{PACKAGE}/{VERSION}/{SOME_RANDOM_STRING}"
},
"7486 warn pnpm:package-requester": {
"message": "Fetching npm.pkg.github.com/{PACKAGE}/{VERSION} failed!",
"prefix": "C:\\tirta-jaya\\order-maker\\order-maker-print"
},
"7487 error pnpm": {
"message": {
"code": "ERR_PNPM_TARBALL_FETCH",
"httpStatusCode": 401,
"uri": "https://npm.pkg.github.com/download/{SCOPE}/{PACKAGE}/{VERSION}/{SOME_RANDOM_STRING}",
"response": {
"size": 0,
"timeout": 0
},
"attempts": 3,
"resource": "https://npm.pkg.github.com/download/{SCOPE}/{PACKAGE}/{VERSION}/{SOME_RANDOM_STRING}"
},
"err": {
"name": "Error",
"message": "401 Unauthorized: https://npm.pkg.github.com/download/{SCOPE}/{PACKAGE}/{VERSION}/{SOME_RANDOM_STRING}",
"code": "ERR_PNPM_TARBALL_FETCH",
"stack": "Error: 401 Unauthorized: https://npm.pkg.github.com/download/{SCOPE}/{PACKAGE}/{VERSION}/{SOME_RANDOM_STRING}\n at fetch (C:\\Users\\USER\\AppData\\Roaming\\npm\\node_modules\\pnpm\\lib\\node_modules\\@pnpm\\tarball-fetcher\\lib\\createDownloader.js:80:27)\n at processTicksAndRejections (internal/process/task_queues.js:94:5)\n at async RetryOperation._fn (C:\\Users\\USER\\AppData\\Roaming\\npm\\node_modules\\pnpm\\lib\\node_modules\\@pnpm\\tarball-fetcher\\lib\\createDownloader.js:45:29)"
}
} |
when I use this configuration then it works:
I don't have the issue that you described |
I've made reproduceable bug in project and library using burner account. To reproduce the bug:
Full .pnpm-debug.log
When I delete |
thanks @gersur I am able to reproduce this issue |
I have found 2 issues. Submitted 2 PRs. |
🚢 5.4.9 |
On Mac OS, just run the below code in your terminal |
I'm trying to install a package, using GitHubs private registries. But it seems that pnpm, does not forward my Personal Access Token, defined in
~/.npmrc
.Following the steps below, yields NO issues, if I'm using
npm
.I've replaced private names, with
{PLACEHOLDER}
.pnpm version:
Code to reproduce the issue:
Add the Github registry, including a Personal Access Token, to your
~/.npmrc
-fileNote: The permissions of the Token used, is:
Add the GitHub org registry, to the
.npmrc
-file of the projectInstall the package
$ cat node_modules/.pnpm-debug.log
Expected behavior:
Expected result, is to install the package without any issues.
Actual behavior:
Fails to install with an error from Github, saying 401 Unauthorized
Additional information:
The text was updated successfully, but these errors were encountered: