node.js - 如何在 npm 的 package.json 中指定本地存储库的存储库 url?

标签 node.js npm

我有一个 nodejs 项目,它位于我本地网络中的服务器上。

我可以使用 npm 成功安装名为“foo”的包

npm install git+ssh://gitolite@my.server:my/project

但是每当我尝试用

更新包时
npm update foo

没有任何反应。

我的第一个想法是我必须像这样在我的 package.json 中指定正确的 url:

{
    "name": "foo",
    "repository": {
        "type": "git",
        "url": "git+ssh://gitolite@my.server:my/project"
    }
    [...]
}

但这行不通。 update 命令总是查找 npm 存储库:

npm http GET https://registry.npmjs.org/foo
npm http 404 https://registry.npmjs.org/foo

如何让 npm 识别正确的本地 url?

最佳答案

对于私有(private)存储库,您必须将其置于依赖项下。

{
    "private": true
    "name": "foo",
    "dependencies": {
        "private-repo": "git+ssh://gitolite@my.server:my/project",
    }
    [...]
}

private 设置为 true 将阻止 npm 发布。

关于node.js - 如何在 npm 的 package.json 中指定本地存储库的存储库 url?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16612077/

相关文章:

node.js - GulpJS 3.9.1 在本地网络上使用安全吗?

node.js - 如何在 react 中自动刷新数据?

node.js - 在生产环境中运行 mongodb

node.js - Mongoose 子模式数组虚拟

node.js - 尝试构建 "Error: self signed certificate in certificate chain"时堆栈 'node-gyp configure'

macos - ~/.npm 目录是干什么用的?

javascript - Node.js 中的 createServer 方法

sql-server - Node js - 导入 mssql 模块以用于 Angular 2 项目错误 : "Can' t resolve 'dns' "and " Can't resolve 'dgram' "

node.js - Grunt 安装错误 : "should be installed with -g"

node.js - npm 安装时 node-gyp 重建在 Mac OS High Sierra 上失败