.npmrc 忽略私有包

Ajo*_*uve 5 node.js npm

我正在尝试在 gitlab 私有实例上使用我的第一个私有 npm 包

我添加@ajouve:registry=https://gitlab.my-website.io/api/v4/packages/npm/.npmrc

该命令npm get似乎返回了正确的配置

; "project" config from /Volumes/Work/service/.npmrc

@ajouve:registry = "https://gitlab.my-website.io/api/v4/packages/npm/" 

; "cli" config from command line options

omit = [] 
user-agent = "npm/7.5.4 node/v12.18.1 darwin x64" 

; node bin location = /usr/local/bin/node
; cwd = /Volumes/Work/service
; HOME = /Users/ajouve
; Run `npm config ls -l` to show all defaults.
Run Code Online (Sandbox Code Playgroud)

但是当我想添加包时

npm install --save @ajouve/my-module

我有

npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@ajouve/my-module Not found
npm ERR! 404 
npm ERR! 404  '@ajouve/my-module@*' 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:
npm ERR!     /Users/ajouve/.npm/_logs/2021-03-19T15_06_50_186Z-debug.log
Run Code Online (Sandbox Code Playgroud)

它转到https://registry.npmjs.org

跑步 npm config ls -l | grep registry

我有

metrics-registry = "https://registry.npmjs.org/"
registry = "https://registry.npmjs.org/"
@ajouve:registry = "https://gitlab.my-website.io/api/v4/packages/npm/"
Run Code Online (Sandbox Code Playgroud)

Moh*_*ahu 0

试试这个,它应该有效。

npm install --save @ajouve/my-module --registry=https://gitlab.my-website.io/api/v4/packages/npm/ 
Run Code Online (Sandbox Code Playgroud)

另一种方法是在私有实例中创建组端点,它将托管+代理指向公共包,并更新注册表以指向该端点,以便私有和公共包都可以工作。