npm error E401: Unable to authenticate, need: Basic realm="GitHub"

6.6k Views Asked by At

I have an issue with node v10.15.1 and npm v6.14.15

Running npm install into the root folder of a project, I have the following error:

npm ERR! code E401
npm ERR! Unable to authenticate, need: Basic realm="GitHub"

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/myuser/.npm/_logs/2022-08-10T17_31_09_840Z-debug.log

The log file reports this:

2675 verbose stack Error: Unable to authenticate, need: Basic realm="GitHub"
2675 verbose stack     at res.buffer.catch.then.body (/Users/myuser/.nvm/versions/node/v10.15.1/lib/node_modules/npm/node_modules/npm-registry-fetch/check-response.js:107:17)
2675 verbose stack     at process._tickCallback (internal/process/next_tick.js:68:7)
2676 verbose statusCode 401
2677 verbose pkgid socket.io-client@https://github.com/substack/socket.io-client/tarball/master
2678 verbose cwd /Users/myuser/myproject
2679 verbose Darwin 20.6.0
2680 verbose argv "/Users/myuser/.nvm/versions/node/v10.15.1/bin/node" "/Users/myuser/.nvm/versions/node/v10.15.1/bin/npm" "install"
2681 verbose node v10.15.1
2682 verbose npm  v6.14.15
2683 error code E401
2684 error Unable to authenticate, need: Basic realm="GitHub"
2685 verbose exit [ 1, true ]

I have other projects that compile perfectly with node v10.15.1 and npm v6.14.15

Any help will be appreciated.

Thanks

1

There are 1 best solutions below

0
On

I solved this problem by myself.

If you have a similar issue, check in your npm configurations if you have the option always-auth=true, typing:

npm config list

In my case, I had :

; userconfig /Users/myuser/.npmrc
always-auth = true

In order to bypass this problem, create a .npmrc file in the root folder of your project and force the property to false:

always-auth = false

Now, npm config list should show you something like this:

; project config /Users/myuser/myproject/.npmrc
always-auth = false

With this configuration you should solve the E401 Basic realm="GitHub"