Skip to content

[BUG] Can't run npm install and can't even run npm whoami without errors using GitHub Packages #2758

Closed
@joshuarobs

Description

@joshuarobs

Current Behavior:

If I run these various commands, I get these errors. Everything seemed to be working fine a month ago and often if things broke, I'd typically look towards regenerating a github token and putting that into my ~/.npmrc file. This started from a few versions ago, around 7.4.3 I believe.

My goal is to have this work normally as usual: install public npm packages as you would without any additional configuration, yet be able to access private packages hosted on GitHub packages.

My .npmrc file in the project folder is:

registry=https://npm.pkg.github.com/joshuarobs

I regenerated a token in this url on GitHub: https://github.com/settings/tokens/ and I copied and pasted it into ~/.npmrc with the contents as follows:

//registry.npmjs.org/:_authToken=XXX
//npm.pkg.github.com/:_authToken=XXX
fund=false
// Running `npm whoami`
joshua@Joshuas-MBP fashion-app-cms-ts % npm whoami
npm ERR! code E404
npm ERR! 404 Not Found - GET https://npm.pkg.github.com/joshuarobs/-/whoami
npm ERR! 404 
npm ERR! 404  'whoami' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/joshua/.npm/_logs/2021-02-22T23_31_44_906Z-debug.log

Not sure why it would consider whoami as a package when clearly its a command.

Anyway, if I also try to run npm install I get a similar issue:

joshua@Joshuas-MBP fashion-app-cms-ts % npm install
npm ERR! code E401
npm ERR! Incorrect or missing password.
npm ERR! If you were trying to login, change your password, create an
npm ERR! authentication token or enable two-factor authentication then
npm ERR! that means you likely typed your password in incorrectly.
npm ERR! Please try again, or recover your password at:
npm ERR!     https://www.npmjs.com/forgot
npm ERR! 
npm ERR! If you were doing some other operation then your saved credentials are
npm ERR! probably out of date. To correct this please try logging in again with:
npm ERR!     npm login

If I try to do as suggested, when I try to run npm login I get:

joshua@Joshuas-MBP fashion-app-cms-ts % npm login
npm notice Log in on https://npm.pkg.github.com/joshuarobs
Username: joshuarobs
Password: 
Email: (this IS public) XXX
npm ERR! code E404
npm ERR! 404 Not Found - PUT https://npm.pkg.github.com/joshuarobs/-/user/org.couchdb.user:joshuarobs
npm ERR! 404 
npm ERR! 404  'org.couchdb.user:joshuarobs' is not in the npm registry.
npm ERR! 404 This package name is not valid, because 
npm ERR! 404  1. name can only contain URL-friendly characters
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

Not sure why I get an error like this, seeing as I entered my details properly and copied and pasted the token in properly.

Expected Behavior:

Everything should work as intended. npm whoami should give a simple result of the username/alias and npm install should install packages.

Steps To Reproduce:

  1. Create an .npmrc file locally in a nodejs project with contents: registry=https://npm.pkg.github.com/[MY_GITHUB_USERNAME]
  2. Create a new token at https://github.com/settings/tokens/ with permissions: repo, workflow and write:packages checked
  3. Create a ~/.npmrc and paste //npm.pkg.github.com/:_authToken=XXX
  4. Copy token that was created in step 2 and replace XXX with that
  5. Try to run npm whoami
  6. Try to install some packages with npm install

Environment:

  • OS: MacOS Big Sur 11.2.1
  • Node: 14.15.1
  • npm: 7.5.6

Metadata

Metadata

Assignees

Labels

Bugthing that needs fixingRelease 7.xwork is associated with a specific npm 7 release

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions