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

401 Unauthorized, installing package from private Github npm registry. #2687

Closed
9 tasks done
jeppech opened this issue Jul 13, 2020 · 18 comments
Closed
9 tasks done

401 Unauthorized, installing package from private Github npm registry. #2687

jeppech opened this issue Jul 13, 2020 · 18 comments
Assignees
Milestone

Comments

@jeppech
Copy link

jeppech commented Jul 13, 2020

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:

$ pnpm --version
5.3.0

Code to reproduce the issue:

Add the Github registry, including a Personal Access Token, to your ~/.npmrc-file

$ cat ~/.npmrc
//npm.pkg.github.com/:_authToken={PERSONAL_ACCESS_TOKEN}

Note: The permissions of the Token used, is:

  • repo - Full control of private repositories
    • repo:status - Access commit status
    • repo_deployment - Access deployment status
    • public_repo - Access public repositories
    • repo:invite - Access repository invitations
    • security_events - Read and write security events
  • write:packages - Upload packages to github package registry
  • read:packages - Download packages from github package registry
  • delete:packages - Delete packages from github package registry

Add the GitHub org registry, to the .npmrc-file of the project

$ cat /my/project/.npmrc
{@SCOPE}:registry=https://npm.pkg.github.com/{ORG}

Install the package

$ pnpm add {@SCOPE}/{PACKAGE}
 ERROR  401 Unauthorized: {@SCOPE}/{PACKAGE} (via https://npm.pkg.github.com/{ORG}/{@SCOPE}%2F{PACKAGE})
Resolving: total 6, reused 4, downloaded
$ cat node_modules/.pnpm-debug.log
{
  "0 debug pnpm:scope": {
    "selected": 1
  },
  "1 debug pnpm:package-manifest": {
    "initial": {
      "scripts": {
        "dev": "rm -rf ./dist && tsc -w --incremental --project tsconfig.json & nodemon",
        "build": "rm -rf ./dist && tsc --project tsconfig.prod.json",
        "build:docker": "npm run build && DOCKER_BUILDKIT=1 docker build -t image:latest ."
      },
      "dependencies": {
        "{@SCOPE}/{PACKAGE}": "^1.5.0",
        "axios": "^0.19.2",
        "ini": "^1.3.5"
      },
      "devDependencies": {
        "@types/ini": "^1.3.30",
        "@types/node": "^13.9.5",
        "nodemon": "^2.0.2",
        "typescript": "^3.8.3"
      }
    },
    "prefix": "/Users/jc/code/project"
  },
  "2 debug pnpm:stage": {
    "prefix": "/Users/jc/code/project",
    "stage": "resolution_started"
  },
  "3 debug pnpm:_dependency_resolved": {
    "resolution": "registry.npmjs.org/@types/ini/1.3.30",
    "wanted": {
      "name": "@types/ini",
      "rawSpec": "^1.3.30"
    }
  },
  "4 debug pnpm:progress": {
    "packageId": "registry.npmjs.org/@types/ini/1.3.30",
    "requester": "/Users/jc/code/project",
    "status": "resolved"
  },
  "5 debug pnpm:_dependency_resolved": {
    "resolution": "registry.npmjs.org/@types/node/13.9.5",
    "wanted": {
      "name": "@types/node",
      "rawSpec": "^13.9.5"
    }
  },
  "6 debug pnpm:progress": {
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "requester": "/Users/jc/code/project",
    "status": "resolved"
  },
  "7 debug pnpm:_dependency_resolved": {
    "resolution": "registry.npmjs.org/nodemon/2.0.2",
    "wanted": {
      "name": "nodemon",
      "rawSpec": "^2.0.2"
    }
  },
  "8 debug pnpm:progress": {
    "packageId": "registry.npmjs.org/nodemon/2.0.2",
    "requester": "/Users/jc/code/project",
    "status": "resolved"
  },
  "9 debug pnpm:_dependency_resolved": {
    "resolution": "registry.npmjs.org/typescript/3.8.3",
    "wanted": {
      "name": "typescript",
      "rawSpec": "^3.8.3"
    }
  },
  "10 debug pnpm:progress": {
    "packageId": "registry.npmjs.org/typescript/3.8.3",
    "requester": "/Users/jc/code/project",
    "status": "resolved"
  },
  "11 debug pnpm:_dependency_resolved": {
    "resolution": "registry.npmjs.org/axios/0.19.2",
    "wanted": {
      "name": "axios",
      "rawSpec": "^0.19.2"
    }
  },
  "12 debug pnpm:progress": {
    "packageId": "registry.npmjs.org/axios/0.19.2",
    "requester": "/Users/jc/code/project",
    "status": "resolved"
  },
  "13 debug pnpm:_dependency_resolved": {
    "resolution": "registry.npmjs.org/ini/1.3.5",
    "wanted": {
      "name": "ini",
      "rawSpec": "^1.3.5"
    }
  },
  "14 debug pnpm:progress": {
    "packageId": "registry.npmjs.org/ini/1.3.5",
    "requester": "/Users/jc/code/project",
    "status": "resolved"
  },
  "15 debug pnpm:progress": {
    "packageId": "registry.npmjs.org/@types/ini/1.3.30",
    "requester": "/Users/jc/code/project",
    "status": "found_in_store"
  },
  "16 debug pnpm:progress": {
    "packageId": "registry.npmjs.org/nodemon/2.0.2",
    "requester": "/Users/jc/code/project",
    "status": "found_in_store"
  },
  "17 debug pnpm:progress": {
    "packageId": "registry.npmjs.org/axios/0.19.2",
    "requester": "/Users/jc/code/project",
    "status": "found_in_store"
  },
  "18 debug pnpm:progress": {
    "packageId": "registry.npmjs.org/ini/1.3.5",
    "requester": "/Users/jc/code/project",
    "status": "found_in_store"
  },
  "19 debug pnpm:fetching-progress": {
    "attempt": 1,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "size": 101720,
    "status": "started"
  },
  "20 debug pnpm:fetching-progress": {
    "downloaded": 649,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "21 debug pnpm:fetching-progress": {
    "downloaded": 2018,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "22 debug pnpm:fetching-progress": {
    "downloaded": 3387,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "23 debug pnpm:fetching-progress": {
    "downloaded": 4756,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "24 debug pnpm:fetching-progress": {
    "downloaded": 6125,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "25 debug pnpm:fetching-progress": {
    "downloaded": 7494,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "26 debug pnpm:fetching-progress": {
    "downloaded": 8863,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "27 debug pnpm:fetching-progress": {
    "downloaded": 10232,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "28 debug pnpm:fetching-progress": {
    "downloaded": 11601,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "29 debug pnpm:fetching-progress": {
    "downloaded": 12970,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "30 debug pnpm:fetching-progress": {
    "downloaded": 14339,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "31 debug pnpm:fetching-progress": {
    "downloaded": 15708,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "32 debug pnpm:fetching-progress": {
    "downloaded": 17077,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "33 debug pnpm:fetching-progress": {
    "downloaded": 18446,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "34 debug pnpm:fetching-progress": {
    "downloaded": 19815,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "35 debug pnpm:fetching-progress": {
    "downloaded": 21184,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "36 debug pnpm:fetching-progress": {
    "downloaded": 22553,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "37 debug pnpm:fetching-progress": {
    "downloaded": 23922,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "38 debug pnpm:fetching-progress": {
    "downloaded": 25291,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "39 debug pnpm:fetching-progress": {
    "downloaded": 26660,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "40 debug pnpm:fetching-progress": {
    "downloaded": 28029,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "41 debug pnpm:fetching-progress": {
    "downloaded": 29398,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "42 debug pnpm:fetching-progress": {
    "downloaded": 30767,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "43 debug pnpm:fetching-progress": {
    "downloaded": 32032,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "44 debug pnpm:fetching-progress": {
    "downloaded": 33401,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "45 debug pnpm:fetching-progress": {
    "downloaded": 34770,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "46 debug pnpm:fetching-progress": {
    "downloaded": 36139,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "47 debug pnpm:fetching-progress": {
    "downloaded": 37508,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "48 debug pnpm:fetching-progress": {
    "downloaded": 38877,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "49 debug pnpm:fetching-progress": {
    "downloaded": 40246,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "50 debug pnpm:fetching-progress": {
    "downloaded": 41615,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "51 debug pnpm:fetching-progress": {
    "downloaded": 42984,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "52 debug pnpm:fetching-progress": {
    "downloaded": 44353,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "53 debug pnpm:fetching-progress": {
    "downloaded": 45722,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "54 debug pnpm:fetching-progress": {
    "downloaded": 47091,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "55 debug pnpm:fetching-progress": {
    "downloaded": 48460,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "56 debug pnpm:fetching-progress": {
    "downloaded": 49829,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "57 debug pnpm:fetching-progress": {
    "downloaded": 51198,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "58 debug pnpm:fetching-progress": {
    "downloaded": 52567,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "59 debug pnpm:fetching-progress": {
    "downloaded": 53936,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "60 debug pnpm:fetching-progress": {
    "downloaded": 55305,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "61 debug pnpm:fetching-progress": {
    "downloaded": 59534,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "62 debug pnpm:fetching-progress": {
    "downloaded": 63763,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "63 debug pnpm:fetching-progress": {
    "downloaded": 64800,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "64 debug pnpm:fetching-progress": {
    "downloaded": 69029,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "65 debug pnpm:fetching-progress": {
    "downloaded": 73258,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "66 debug pnpm:fetching-progress": {
    "downloaded": 77487,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "67 debug pnpm:fetching-progress": {
    "downloaded": 81716,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "68 debug pnpm:fetching-progress": {
    "downloaded": 85945,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "69 debug pnpm:fetching-progress": {
    "downloaded": 90174,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "70 debug pnpm:fetching-progress": {
    "downloaded": 94403,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "71 debug pnpm:fetching-progress": {
    "downloaded": 97568,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "72 debug pnpm:fetching-progress": {
    "downloaded": 101720,
    "packageId": "registry.npmjs.org/@types/node/13.9.5",
    "status": "in_progress"
  },
  "73 error pnpm": {
    "message": {
      "code": "ERR_PNPM_REGISTRY_META_RESPONSE_401",
      "package": "{@SCOPE}/{PACKAGE}",
      "response": {
        "size": 0,
        "timeout": 0
      },
      "uri": "https://npm.pkg.github.com/{ORG}/{@SCOPE}%2F{PACKAGE}",
      "pkgsStack": []
    },
    "err": {
      "name": "Error",
      "message": "401 Unauthorized: {@SCOPE}/{PACKAGE} (via https://npm.pkg.github.com/{ORG}/{@SCOPE}%2F{PACKAGE})",
      "code": "ERR_PNPM_REGISTRY_META_RESPONSE_401",
      "stack": "Error: 401 Unauthorized: {@SCOPE}/{PACKAGE} (via https://npm.pkg.github.com/{ORG}/{@SCOPE}%2F{PACKAGE})\n    at fromRegistry (/Users/jc/.node/pnpm/pnpm-global/4/node_modules/.pnpm/pnpm@5.3.0/node_modules/pnpm/lib/node_modules/@pnpm/npm-resolver/lib/fetch.js:24:15)\n    at processTicksAndRejections (internal/process/task_queues.js:97:5)"
    }
  }
}

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:

$ node -v
v14.4.0

$ system_profiler SPSoftwareDataType
Software:

    System Software Overview:

      System Version: macOS 10.15.5 (19F101)
      Kernel Version: Darwin 19.5.0
      Boot Volume: Macintosh HD
      Boot Mode: Normal

@jeppech
Copy link
Author

jeppech commented Jul 13, 2020

I just updated to v5.4.0, the issue still persists.

@zkochan
Copy link
Member

zkochan commented Jul 14, 2020

Could you try to set the auth token like this?

//npm.pkg.github.com/{ORG}:_authToken={PERSONAL_ACCESS_TOKEN}

@jeppech
Copy link
Author

jeppech commented Jul 15, 2020

That yields the same error.

@zkochan zkochan self-assigned this Jul 15, 2020
@zkochan zkochan removed their assignment Jul 15, 2020
@milind009
Copy link

milind009 commented Jul 18, 2020

I was facing a similar issue. Two things I observed-

  1. When I used _auth={Base64encodedToken} in the .npmrc file, it showed unable to authenticate with error 401.
  2. When the used the token in this format
    //office.pkgs.visualstudio.com/_packaging/OneShell/npm/registry/:username=o{USERNAME} //office.pkgs.visualstudio.com/_packaging/OneShell/npm/registry/:_password={Base64encodedToken} //office.pkgs.visualstudio.com/_packaging/OneShell/npm/registry/:email={EMAIL}
    It was able to authenticate the requests.
    What could be the reason behind this? What is the proper way to define tokens in .npmrc file for authentication?

@jeppech
Copy link
Author

jeppech commented Jul 20, 2020

@jeppech
Copy link
Author

jeppech commented Jul 20, 2020

@zkochan This might help - I set up a dumb server, that logs the request headers.

These are the headers pnpm sets, on the initial request:

HTTP_HOST: test.codr.dk
HTTP_CONNECTION: keep-alive
HTTP_ACCEPT: application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*
HTTP_USER_AGENT: pnpm/5.4.0 npm/? node/v12.18.2 darwin x64

And these are what NPM sets, on the initial request:

HTTP_HOST: test.codr.dk
HTTP_ACCEPT_ENCODING: gzip,deflate
HTTP_AUTHORIZATION: Bearer {PERSONAL_ACCESS_TOKEN}
HTTP_ACCEPT: application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*
HTTP_PACOTE_PKG_ID: registry:{@SCOPE}/{PACKAGE}
HTTP_PACOTE_REQ_TYPE: packument
HTTP_REFERER: install
HTTP_NPM_SESSION: 1149b04173e94d83
HTTP_NPM_SCOPE:
HTTP_NPM_IN_CI: false
HTTP_USER_AGENT: npm/6.14.5 node/v12.18.2 darwin x64
HTTP_CONNECTION: keep-alive
HTTPS: on

@zkochan
Copy link
Member

zkochan commented Jul 20, 2020

Here's the code that is getting the auth information from .npmrc. I tested it with your configuration and it seems to work with it.

Maybe pnpm doesn't find the global .npmrc file? Try to set the auth configuration in a .npmrc file the is in the root of your project.

@jeppech
Copy link
Author

jeppech commented Jul 20, 2020

I'm pretty sure that pnpm sees the ~/.npmrc, as I have other config settings that it uses. For instance pnpm-prefix and store-dir. Or are those values not resolved in the same matter as the authToken? Just for the sake of it, I tried removing both pnpm-prefix and store-dir from the config, to ensure they're not causing it. That did not change anything, either.

I just tried putting the auth config, in my project root-.npmrc. Unfortunately, that did not help either.

I'm curious to know, what you did exactly. Something must be different.

@zkochan
Copy link
Member

zkochan commented Jul 24, 2020

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

@SukkaW
Copy link
Contributor

SukkaW commented Jul 27, 2020

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 credentials-by-uri could be debugged by others.

I have setup a example based on credentials-by-uri's README: https://runkit.com/sukkaw/5f1e7a60ad881b001b3e36d2

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.

@zkochan
Copy link
Member

zkochan commented Jul 27, 2020

The registry option should be always set: https://runkit.com/zkochan/5f1e8c8fd2a7f4001a8e9665

@gersur
Copy link

gersur commented Jul 28, 2020

I can get private github package registry working in my project.

.npmrc in root project

//npm.pkg.github.com/:_authToken={PERSONAL_ACCESS_TOKEN}

@{SCOPE}:registry=https://npm.pkg.github.com

Then follow the instruction in github package detail page, but using pnpm

pnpm install @{SCOPE}/{PACKAGE}@{VERSION}

But, it only works if the package never installed before.

When I delete .pnpm-store and run pnpm i.

401 Unauthorized: https://npm.pkg.github.com/download/@{SCOPE}/{PACKAGE}/{VERSION}/{SOME_RANDOM_STRING}
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)"
    }
  }

@zkochan
Copy link
Member

zkochan commented Jul 28, 2020

when I use this configuration then it works:

//npm.pkg.github.com/:_authToken={PERSONAL_ACCESS_TOKEN}

@{SCOPE}:registry=https://npm.pkg.github.com

I don't have the issue that you described

@gersur
Copy link

gersur commented Jul 29, 2020

I've made reproduceable bug in project and library using burner account.
I've set the library to be private, but here is the download link to download library

To reproduce the bug:

  1. Donwload/clone project
  2. Remove // in .npmrc auth token, so it become //npm.pkg.github.com/:_authToken=90d...
  3. Run pnpm i
Full .pnpm-debug.log
{
  "0 debug pnpm:scope": {
    "selected": 1
  },
  "1 debug pnpm:package-manifest": {
    "initial": {
      "name": "test-pnpm-private-registry-project",
      "version": "1.0.0",
      "description": "",
      "main": "app.js",
      "scripts": {
        "preinstall": "npx only-allow pnpm",
        "start": "node app.js"
      },
      "repository": {
        "type": "git",
        "url": "git+https://github.com/gersur1/test-pnpm-private-registry-project.git"
      },
      "author": "gersur1",
      "license": "MIT",
      "bugs": {
        "url": "https://github.com/gersur1/test-pnpm-private-registry-project/issues"
      },
      "homepage": "https://github.com/gersur1/test-pnpm-private-registry-project#readme",
      "dependencies": {
        "@gersur1/test-pnpm-private-registry": "^1.0.0"
      },
      "engines": {
        "node": ">=10",
        "pnpm": ">=5"
      }
    },
    "prefix": "C:\\Repository\\test-pnpm-private-registry-project"
  },
  "2 debug pnpm:context": {
    "currentLockfileExists": false,
    "storeDir": "C:\\Repository\\test-pnpm-private-registry-project\\.pnpm-store-local\\v3",
    "virtualStoreDir": "C:\\Repository\\test-pnpm-private-registry-project\\node_modules\\.pnpm"
  },
  "3 info pnpm": {
    "message": "Lockfile is up-to-date, resolution step is skipped",
    "prefix": "C:\\Repository\\test-pnpm-private-registry-project"
  },
  "4 debug pnpm:stats": {
    "prefix": "C:\\Repository\\test-pnpm-private-registry-project",
    "removed": 0
  },
  "5 debug pnpm:stage": {
    "prefix": "C:\\Repository\\test-pnpm-private-registry-project",
    "stage": "importing_started"
  },
  "6 debug pnpm:progress": {
    "packageId": "npm.pkg.github.com/test-pnpm-private-registry/1.0.0",
    "requester": "C:\\Repository\\test-pnpm-private-registry-project",
    "status": "resolved"
  },
  "7 debug pnpm:stats": {
    "added": 1,
    "prefix": "C:\\Repository\\test-pnpm-private-registry-project"
  },
  "8 debug pnpm:request-retry": {
    "attempt": 1,
    "error": {
      "code": "ERR_PNPM_TARBALL_FETCH",
      "httpStatusCode": 401,
      "uri": "https://npm.pkg.github.com/download/@gersur1/test-pnpm-private-registry/1.0.0/fd28662f8de5c95d5649f5c7259a55471efa4a3d0d10bcba0c8d6774f8974915",
      "response": {
        "size": 0,
        "timeout": 0
      },
      "attempts": 1,
      "resource": "https://npm.pkg.github.com/download/@gersur1/test-pnpm-private-registry/1.0.0/fd28662f8de5c95d5649f5c7259a55471efa4a3d0d10bcba0c8d6774f8974915"
    },
    "maxRetries": 2,
    "method": "GET",
    "timeout": 10000,
    "url": "https://npm.pkg.github.com/download/@gersur1/test-pnpm-private-registry/1.0.0/fd28662f8de5c95d5649f5c7259a55471efa4a3d0d10bcba0c8d6774f8974915"
  },
  "9 debug pnpm:request-retry": {
    "attempt": 2,
    "error": {
      "code": "ERR_PNPM_TARBALL_FETCH",
      "httpStatusCode": 401,
      "uri": "https://npm.pkg.github.com/download/@gersur1/test-pnpm-private-registry/1.0.0/fd28662f8de5c95d5649f5c7259a55471efa4a3d0d10bcba0c8d6774f8974915",
      "response": {
        "size": 0,
        "timeout": 0
      },
      "attempts": 2,
      "resource": "https://npm.pkg.github.com/download/@gersur1/test-pnpm-private-registry/1.0.0/fd28662f8de5c95d5649f5c7259a55471efa4a3d0d10bcba0c8d6774f8974915"
    },
    "maxRetries": 2,
    "method": "GET",
    "timeout": 60000,
    "url": "https://npm.pkg.github.com/download/@gersur1/test-pnpm-private-registry/1.0.0/fd28662f8de5c95d5649f5c7259a55471efa4a3d0d10bcba0c8d6774f8974915"
  },
  "10 warn pnpm:package-requester": {
    "message": "Fetching npm.pkg.github.com/test-pnpm-private-registry/1.0.0 failed!",
    "prefix": "C:\\Repository\\test-pnpm-private-registry-project"
  },
  "11 error pnpm": {
    "message": {
      "code": "ERR_PNPM_TARBALL_FETCH",
      "httpStatusCode": 401,
      "uri": "https://npm.pkg.github.com/download/@gersur1/test-pnpm-private-registry/1.0.0/fd28662f8de5c95d5649f5c7259a55471efa4a3d0d10bcba0c8d6774f8974915",
      "response": {
        "size": 0,
        "timeout": 0
      },
      "attempts": 3,
      "resource": "https://npm.pkg.github.com/download/@gersur1/test-pnpm-private-registry/1.0.0/fd28662f8de5c95d5649f5c7259a55471efa4a3d0d10bcba0c8d6774f8974915"
    },
    "err": {
      "name": "Error",
      "message": "401 Unauthorized: https://npm.pkg.github.com/download/@gersur1/test-pnpm-private-registry/1.0.0/fd28662f8de5c95d5649f5c7259a55471efa4a3d0d10bcba0c8d6774f8974915",
      "code": "ERR_PNPM_TARBALL_FETCH",
      "stack": "Error: 401 Unauthorized: https://npm.pkg.github.com/download/@gersur1/test-pnpm-private-registry/1.0.0/fd28662f8de5c95d5649f5c7259a55471efa4a3d0d10bcba0c8d6774f8974915\n    at fetch (C:\\Users\\ger_2\\AppData\\Roaming\\npm\\pnpm-global\\4\\node_modules\\.pnpm\\pnpm@5.4.8\\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\\ger_2\\AppData\\Roaming\\npm\\pnpm-global\\4\\node_modules\\.pnpm\\pnpm@5.4.8\\node_modules\\pnpm\\lib\\node_modules\\@pnpm\\tarball-fetcher\\lib\\createDownloader.js:45:29)"
    }
  }
}

When I delete pnpm-lock.yaml and run pnpm i, it sucessfully install

@zkochan
Copy link
Member

zkochan commented Jul 30, 2020

thanks @gersur

I am able to reproduce this issue

@zkochan
Copy link
Member

zkochan commented Jul 30, 2020

I have found 2 issues. Submitted 2 PRs.

@zkochan
Copy link
Member

zkochan commented Jul 31, 2020

🚢 5.4.9

@adewumiadedeji
Copy link

On Mac OS, just run the below code in your terminal
echo "//npm.pkg.github.com/:_authToken= your access token" >> ~/.npmrc

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

No branches or pull requests

6 participants