Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Error: 401 Unauthorized when using private NPM registry #18309

Closed
3 tasks
denver-HJS opened this issue Aug 25, 2017 · 5 comments
Closed
3 tasks

Error: 401 Unauthorized when using private NPM registry #18309

denver-HJS opened this issue Aug 25, 2017 · 5 comments

Comments

@denver-HJS
Copy link

I'm opening this issue because:

  • [x ] npm is crashing.
  • npm is producing an incorrect install.
  • npm is doing something I don't understand.
  • Other (see below for feature requests):

What's going wrong?

I'm trying to run the npm CLI connecting to a private registry. It seems a fix went in prior to this version according to #16528 but the issue is still occurring for me on npm CLI v5.3.0 and Nexus Repository Manager OSS 3.0.1-01.

bohling.denver@IFB389968 MINGW64 /c/temp/npm-test
$ npm -v
5.3.0

bohling.denver@IFB389968 MINGW64 /c/temp/npm-test
$ npm info --verbose
npm info it worked if it ends with ok
npm verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
npm verb cli   'C:\\Users\\bohling.denver\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
npm verb cli   'info',
npm verb cli   '--verbose' ]
npm info using npm@5.3.0
npm info using node@v7.2.1
npm verb request uri https://nexusrepo.myrepo.com:8443/repository/group/npm-test
npm verb request no auth needed
npm info attempt registry request try #1 at 3:09:18 PM
npm verb request using bearer token for auth
npm verb request id 57f7c8ee54ce5aac
npm http request GET https://nexusrepo.myrepo.com:8443/repository/group/npm-test
npm http 401 https://nexusrepo.myrepo.com:8443/repository/group/npm-test
npm verb headers { date: 'Fri, 25 Aug 2017 22:09:18 GMT',
npm verb headers   server: 'Nexus/3.0.1-01 (OSS)',
npm verb headers   'x-frame-options': 'SAMEORIGIN',
npm verb headers   'x-content-type-options': 'nosniff',
npm verb headers   'set-cookie': [ 'NXREMEMBERME=deleteMe; Path=/; Max-Age=0; Expires=Thu, 24-Aug-2017 22:09:18 GMT' ],
npm verb headers   'www-authenticate': 'BASIC realm="Sonatype Nexus"',
npm verb headers   'content-length': '0' }
npm verb stack Error: 401 Unauthorized
npm verb stack     at makeError (C:\Users\bohling.denver\AppData\Roaming\npm\node_modules\npm\node_modules\npm-registry-client\lib\request.js:314:12)
npm verb stack     at RegClient.<anonymous> (C:\Users\bohling.denver\AppData\Roaming\npm\node_modules\npm\node_modules\npm-registry-client\lib\request.js:259:9)
npm verb stack     at Request._callback (C:\Users\bohling.denver\AppData\Roaming\npm\node_modules\npm\node_modules\npm-registry-client\lib\request.js:216:14)
npm verb stack     at Request.self.callback (C:\Users\bohling.denver\AppData\Roaming\npm\node_modules\npm\node_modules\request\request.js:188:22)
npm verb stack     at emitTwo (events.js:106:13)
npm verb stack     at Request.emit (events.js:191:7)
npm verb stack     at Request.<anonymous> (C:\Users\bohling.denver\AppData\Roaming\npm\node_modules\npm\node_modules\request\request.js:1171:10)
npm verb stack     at emitOne (events.js:96:13)
npm verb stack     at Request.emit (events.js:188:7)
npm verb stack     at IncomingMessage.<anonymous> (C:\Users\bohling.denver\AppData\Roaming\npm\node_modules\npm\node_modules\request\request.js:1091:12)
npm verb statusCode 401
npm verb cwd C:\temp\npm-test
npm verb Windows_NT 6.1.7601
npm verb argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\bohling.denver\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "info" "--verbose"
npm verb node v7.2.1
npm verb npm  v5.3.0
npm ERR! code E401
npm ERR! 401 Unauthorized
npm verb exit [ 1, true ]

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\bohling.denver\AppData\Roaming\npm-cache\_logs\2017-08-25T22_09_18_994Z-debug.log

npm config

registry=https://nexusrepo.myrepo.com:8443/repository/group/
_auth=<redacted>
always-auth=true
email=<redacted>

Is _auth still the proper way to transmit credentials since npm v5.3.0 was released?

@denver-HJS
Copy link
Author

Closing this as the root cause was on the Nexus Repository side, not the npm CLI.

@devuke
Copy link

devuke commented Jan 2, 2018

Hi @denver-HJS,

What was the issue at Nexus side? Can you please let me know as I am facing same issue here?

Thanks,

@denver-HJS
Copy link
Author

Hi @devuke, unfortunately my visibility into our internal Nexus repo and what was done is limited. Ultimately there were some changes of this fashion and a reboot of the server, and one of those two things is what fixed this issue.

@vtabary
Copy link

vtabary commented Apr 5, 2018

Hi all,

FYI my nexus server wasn't correctly configured. I had to to go the admin, in "Security > Realms" and enable the "npm Bearer Token Realm".

Since everything is working fine.

Hope this will help someone

See "npm Security" http://books.sonatype.com/nexus-book/3.0/reference/npm.html

@todvora
Copy link

todvora commented Apr 26, 2018

Thank you @vtabary, I had the same issue, your tip

go the admin, in "Security > Realms" and enable the "npm Bearer Token Realm"

finally resolved it.

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

No branches or pull requests

4 participants