node.js - .npmrc 忽略了私有包
问题描述
我正在尝试在 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.
但是当我想添加包时
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
跑步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/"
解决方案
代替 git://,使用 git+ssh://
npm i -S git+ssh://git@gitlab.com:<org>/<project>.git
在这里你可以得到几个答案
推荐阅读
- vue.js - Vue 如何正确绑定 src 与 API 的输出
- java - 如何从 Firestore 文档中获取自定义对象的 ArrayList?
- reactjs - http-proxy-middleware 在 Heroku 上不起作用
- google-cloud-firestore - 如何让我的 Cloud Function 读取/写入 Firestore?
- c - C 程序中的幽灵正在更改数组元素的值而无需声明
- reactjs - this() 方法指的是什么?
- visual-studio-code - prettier 不会格式化导出对象之间的间距
- mongodb - mongo/mongoose: 聚合: 查找 *DON'T* 在数组字段中有 ref 的文档?
- r - 在 R 中使用带有 If 语句的函数中使用循环
- javascript - 如何从下拉列表中链接到带有所选项目的页面