问题
I am trying to use npm to install a package from url : http://host:80
I did the following: npm config set strict-ssl false npm config set registry "<>" npm --proxy http://host:port install <> (our proxy does not require authentication)
When I tired to run above install package command it throws npm ERR! code E401 npm ERR! 401 Authorization Required: @latest
When I should I set the username and pwd for registry url.I googled and found that registry url and details are part of .npmrc file.
Currently it has
strict-ssl=false
registry=<>enter code here
Should I add username and password here in this file ? If so can you give me the format or how to add it or where to add it.Thank you.
回答1:
If you want to auth to your NPM registry (like Artifactory)
You can provide the login details as below at runtime
npm login
Alternatively you can paste following in the .npmrc file.
_auth = <USERNAME>:<PASSWORD> (converted to base 64)
email = youremail@email.com
always-auth = true
If you are getting any SSL issues you can add following to disable SSL
strict-ssl=false
If you want to configure proxy settings
npm config set proxy http://"username:mystrongpassword"@proxy.mycompany.com:PORT
npm config set https-proxy http://"username:mystrongpassword"@proxy.mycompany.com:PORT
来源:https://stackoverflow.com/questions/50612549/setting-up-username-and-password-for-npm-registry-url