私有 npm 注册表的 npm 安装失败

时间:2021-07-29 06:36:12

标签: npm scope gitlab npm-install npm-registry

我使用 gitlab 创建了一个私有的 npm 注册表

我有以下 .npmrc 文件,它与我过去发布的 .npmrc 文件相同,没有出现任何问题。我已经用占位符替换了所有公司价值观。

@myorg:registry=https://gitlab.com/api/v4/packages/npm/
//gitlab.com/api/v4/packages/npm/:_authToken=[[MY_TOKEN_HERE]]
//gitlab.com/api/v4/projects/12345678/packages/npm/:_authToken=[[MY_TOKEN_HERE]]

当我去安装时,我收到以下错误消息

npm install @myorg/my-package-name-here
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@myorg/my-package-name-here - Not found
npm ERR! 404
npm ERR! 404  '@myorg/my-package-name-here@latest' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:

在我看来,由于注册表不同,它似乎没有选择 .npmrc 文件。

我已经检查过,该文件肯定是 .npmrc 而不是不同的扩展名等。

有人有什么想法吗?

编辑

我做了一些调查,看起来我的 .npmrc 文件正在被使用,但是注册表

'https://gitlab.com/api/v4/packages/npm/@myorg/my-package-name-here'

正在重定向到

'https://registry.npmjs.org/@myorg/my-package-name-here'

这就是为什么它会显示为这个...

它没有向我解释为什么使用我以前发布的身份验证令牌等找不到它?

1 个答案:

答案 0 :(得分:0)

我已经想通了...

除了 @myorg 与我的 gitlab 组织名称不匹配之外,一切都很好。

例如gitlab 网址是这样的:

https://gitlab.com/my-company/...

相反,它需要匹配github url,所以在上面的例子中

@my-company

切换后,一切都开始了,我能够获得 npm 包。