acme
acme

Reputation: 14856

How to specify the repository url of a local repository in a package.json for NPM?

I have a nodejs project that's located on a server within my local network.

I can successfully install the package named 'foo' with npm with

npm install git+ssh://[email protected]:my/project

But whenever I try to update the package with

npm update foo

nothing happens.

My first thought was I have to specify the correct url in my package.json like this:

{
    "name": "foo",
    "repository": {
        "type": "git",
        "url": "git+ssh://[email protected]:my/project"
    }
    [...]
}

But this does not work. The update command always looks up the npm repository:

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

How can I make npm recognize the correct local url?

Upvotes: 5

Views: 7176

Answers (1)

user568109
user568109

Reputation: 48003

For private repository you have to put it under dependencies.

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

Setting private to true will prevent npm from publishing.

Upvotes: 2

Related Questions