如何在 NPM 的 package.json 中指定本地存储库的存储库 url?

acm*_*cme 5 node.js npm

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

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

npm install git+ssh://gitolite@my.server:my/project
Run Code Online (Sandbox Code Playgroud)

但每当我尝试用以下命令更新软件包时

npm update foo
Run Code Online (Sandbox Code Playgroud)

什么都没发生。

我的第一个想法是我必须在 package.json 中指定正确的 url,如下所示:

{
    "name": "foo",
    "repository": {
        "type": "git",
        "url": "git+ssh://gitolite@my.server:my/project"
    }
    [...]
}
Run Code Online (Sandbox Code Playgroud)

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

npm http GET https://registry.npmjs.org/foo
npm http 404 https://registry.npmjs.org/foo
Run Code Online (Sandbox Code Playgroud)

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

use*_*109 2

对于私有存储库,您必须将其放在依赖项下。

{
    "private": true
    "name": "foo",
    "dependencies": {
        "private-repo": "git+ssh://gitolite@my.server:my/project",
    }
    [...]
}
Run Code Online (Sandbox Code Playgroud)

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