Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NPM install resulting in 401 Unauthorized for private repo

I have the following line in my dependencies in package.json:

"log": "https://git.mydomain.com/myproject/myrepo/repository/archive.tar.gz?ref=0.1.0", 

I get the following:

km@Karls-MBP ~/dev/vertica (km/ref) $ npm install npm ERR! code E401 npm ERR! 404 401 Unauthorized: log@https://git.mydomain.com/myproject/myrepo/repository/archive.tar.gz?ref=0.5.0  npm ERR! A complete log of this run can be found in: npm ERR!     /Users/km/.npm/_logs/2018-02-16T08_49_38_669Y-debug.log 

I don't know if the issue is GitLab (where the repo exists) or NPM.

  • Node v8.9.4
  • NPM v5.6.0
like image 487
basickarl Avatar asked Feb 16 '18 09:02

basickarl


People also ask

How do I prevent npm install from removing packages?

To Save : npm install --save {package_name} . This will save the package to package. json and install using npm install . You can't particularly control the dependencies(fully).

What does npm Adduser do?

adduser npm-adduser The username, password, and email are read in from prompts. You may use this command multiple times with the same user account to authorize on a new machine. When authenticating on a new machine, the username, password and email address must all match with your existing record.


2 Answers

Remove .npmrc from the Home Directory, it should be able to work. I did the same and it works for me.

like image 164
Abdullah Faruk Avatar answered Sep 20 '22 03:09

Abdullah Faruk


My user directory .npmrc file had a stale authtoken as below.

//registry.npmjs.org/:_authToken=3615fa68-123a-4d72-b99a-772b5b1edc48

By removing this line, the npm installation works fine and no longer throws an authentication error.

like image 31
santon Avatar answered Sep 21 '22 03:09

santon