12

I have published a package to the GitHub npm registry. I can see the package when I login onto GitHub, as per the screenshots below.

ScreenShot 1 enter image description here

ScreenShot 2 enter image description here

Locally, a different package has the former as a dependency. Therefore I have on my package.json:

"dependencies": {
    "<@scope>/<package_name>": "1.2.0",
...

I also have, in-line with the documentation, a .npmrc file at the same directory as the package.json with the authToken. This authToken has all the permissions necessary (delete:packages, read:packages, repo, write:packages)

//npm.pkg.github.com/:_authToken=<my_auth_token>
registry=https://npm.pkg.github.com/OWNER

Lastly, I have on package.json the following two entries. Although I believe these are necessary to publish packages to the github registry, no to install them which is the current problem.

  "publishConfig": {
    "registry": "https://npm.pkg.github.com/"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/<OWNER>/<REPO>.git"
  }

So, the error that I am having when I try to install the package is:

npm ERR! code E404
npm ERR! 404 Not Found: <@scope>/<package_name>@1.2.0

When I tried to understand what was going on with some helpful logs: With npm install @<scope>/<package_name>@1.2.0 --loglevels verbose, I see:

....
npm http fetch GET 200 https://npm.pkg.github.com/OWNER/@<scope>%2f<package_name>
npm http fetch GET 404 https://npm.pkg.github.com/download/@<scope>/<package_name>/1.2.0/98e69e2adddec5c715a32c94352efac83ce586e4e6f3d06fef1fc1f82d238r34
...

The first http request is a success, which seems to indicate things are correctly wired up and authenticated. However, I have no idea why I am getting a 404 afterwards. The package is clearly there as we see on the image above.

Does anyone had a similar problem ?

2
  • 1
    I am having the same problem. I have noticed that when I run npm info @scope/name it works fine, but it's the install step that fails. It happens both with yarn and npm client.
    – albertfdp
    Commented Nov 30, 2019 at 15:33
  • Did you manage to solve it? Commented Nov 5, 2021 at 19:08

4 Answers 4

7

Well, my own .npmrc (in my home directory) is configured as this:

//registry.npmjs.org/:_authToken=<token>
//npm.pkg.github.com/:_authToken=<token>
@myorg1:registry=https://npm.pkg.github.com
@myorg2:registry=https://registry.npmjs.org

I've not added my org in the github registry URL as you did, and specified the registry to use for each scope.

1

I just ran into the same issue. Removing package-lock.json fixed it for me. I suspect the problem was that I previously installed the offending package from a tarball and that the old installation information was somehow cached inside the package-lock.json

0

I had misread the checkboxes in my PAT. Make sure you've enabled read:packages.

My successful .npmrc file looks like this:

//npm.pkg.github.com/:_authToken=TOKEN_GOES_HERE
0

I had a similar problem where I was getting 404 and 403. I ended up changing my .npmrc to look like this:

@myusername:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=TOKEN

Now it works like a charm.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.