为 npm 注册表 URL 设置用户名和密码 [英] Setting up username and password for npm registry URL

查看:173
本文介绍了为 npm 注册表 URL 设置用户名和密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 npm 从 url 安装软件包:http://host:80

I am trying to use npm to install a package from url : http://host:80

我做了以下事情:npm 配置设置严格的 SSL 假npm 配置集注册表<>"npm --proxy http://host:port install <>(我们的代理不需要身份验证)

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)

当我厌倦运行上面的安装包命令时,它会抛出npm 错误!代码 E401npm 错误!401 需要授权:@latest

When I tired to run above install package command it throws npm ERR! code E401 npm ERR! 401 Authorization Required: @latest

我应该何时为注册表 url 设置用户名和密码.我用谷歌搜索并发现注册表 url 和详细信息是 .npmrc 文件的一部分.

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.

目前有严格 ssl=falseregistry=<>在此处输入代码

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.

推荐答案

如果你想授权到你的 NPM 注册表(比如 Artifactory)

您可以在运行时提供如下登录详细信息

You can provide the login details as below at runtime

npm login

或者,您可以将以下内容粘贴到 .npmrc 文件中.

Alternatively you can paste following in the .npmrc file.

_auth = <USERNAME>:<PASSWORD> (converted to base 64)
email = youremail@email.com
always-auth = true

如果您遇到任何 SSL 问题,您可以添加以下内容以禁用 SSL

If you are getting any SSL issues you can add following to disable SSL

strict-ssl=false

如果要配置代理设置

npm config set proxy http://"username:mystrongpassword"@proxy.mycompany.com:PORT
npm config set https-proxy http://"username:mystrongpassword"@proxy.mycompany.com:PORT

这篇关于为 npm 注册表 URL 设置用户名和密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆