setec
setec

Reputation: 16090

How to setup NPM 'git' dependency to not download each time

I've a NPM git dependency like this:

//package.json
{  ... 
    dependencies: {
        'mylib': 'http://repo.com/mylib.git#develop'
    }
}

Each time when npm install is called, NPM attempts do download whole mylib repository.

Is there a way to tell NPM to avoid that and still keep local copy of repository at node_modules/mylib up to date?

Upvotes: 1

Views: 64

Answers (1)

Nick Ribal
Nick Ribal

Reputation: 2109

Unfortunately, you won't find that functionality officially supported by npm itself. In fact, searching npm's docs and guides doesn't yield any results, and searching npm's issues shows some light into it partially working, but not in a production ready way.

There are a few additional options to make it work, but personally I didn't try these, since I don't want to depend on anything that's not 100% reliable.

Try yarn, which has offline installs as a feature.

Upvotes: 3

Related Questions