DevOpsDockerDockersHow to

How to set _auth in .npmrc when using a Nexus https npm private registry or and proxy?

; Nexus proxy registry pointing to http://nexus.domain.com/
registry = https:///nexus/content/repositories/npmjs-registry/
; base64 encoded authentication token
_auth =
; required by Nexus
email =
; force auth to be used for GET requests
always-auth = true
; we don't want to put certificates in .npmrc
strict-ssl = false
loglevel = silly

How to generate the _auth property properly in order to have npm install work as expected?

  1. base64Encode(:)
    • results in npm info retry will retry, error on last attempt: Error: socket hang up
  2. base64Encode(urlencode(:))
    • results in npm info retry will retry, error on last attempt: Error: This request requires auth credentials. Run npm login and repeat the request.
  3. base64Encode(urlencode():urlencode())
    • results in npm info retry will retry, error on last attempt: Error: socket hang up
      When getting the socket hang up error I have the following stack trace:
$ echo -n 'username:password' | openssl base64

After having looked at registry-client code I found the answer, here it is. I post it as it may help other people:

base64Encode(:)

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

7Zs6 8Zb U

Please type the text above:

Check Also

Close
Close
Close