NPM安装导致401 Unauthorized私人回购

Kar*_*son 15 node.js npm gitlab

我的依赖项中有以下行package.json:

"log": "https://git.mydomain.com/myproject/myrepo/repository/archive.tar.gz?ref=0.1.0",
Run Code Online (Sandbox Code Playgroud)

我得到以下内容:

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
Run Code Online (Sandbox Code Playgroud)

我不知道问题是GitLab(存在repo的地方)还是NPM.

  • 节点v8.9.4
  • NPM v5.6.0

Abd*_*ruk 31

从主目录中删除.npmrc,它应该能够工作.我做了同样的事,它对我有用.

  • 如果您需要 .npmrc 文件对 vpn 上的服务进行身份验证怎么办? (7认同)
  • 这永远不适用于私人仓库 (6认同)
  • 那对我有用。就我而言,打印 401 的是“npm install -g @vue/cli”。这个解决方案的目的是什么? (3认同)

Sal*_*twa 11

您需要将用户添加到 npm registery

>> npm whoami [ it will return not authorized ]
Run Code Online (Sandbox Code Playgroud)

要添加新用户,请按照以下步骤操作:-

>> npm adduser  (then enter your name and complex password and your email)

>> npm whoami   (return your registered name)
Run Code Online (Sandbox Code Playgroud)


san*_*ton 7

我的用户目录.npmrc文件具有过期的身份验证,如下所示。

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

通过删除此行,npm安装可以正常工作,并且不再引发身份验证错误。