--skip-installed flag for `npm install` #2388

wants to merge 3 commits into

I don't have tests for this because I couldn't see how to work them in to the existing test structure as this is just an extra flag for npm install, if you'd like tests then could you point me in the right direction to get started?

npm install <package1> [<package2>...] --skip-installed will act a little like a plain npm install does on a directory with a package.json, that is, it'll skip any packages that already exist in the node_modules directory:

$ npm install foo bar
$ # → foo and bar installed into node_modules
$ npm install foo bar --skip-installed
$ # → nothing is done, they are already there
$ npm install foo bar baz --skip-installed
$ # → baz installed into node_modules

Additionally, semver matching is performed so you can do it by version, and even semver ranges (basically it's all passed to `semver.satisies, so you can do:

$ npm install foo@0.0.5
$ # → foo@0.0.5 installed to node_modules
$ npm install foo@0.0.5 --skip-installed
$ # → nothing happens
$ npm install foo@0.0.6 --skip-installed
$ # → foo@0.0.6 installed to node_modules
$ npm install 'foo@>=0.0.4' --skip-installed
$ # → nothing happens
$ npm install 'foo@>=0.0.10' --skip-installed
$ # → foo@* (latest) installed to node_modules

The main reason I want this is for use via the API in Ender so we can do ender build pkg1 pkg2 pkg3 and have it act like a plain npm install, i.e. not install anything if it's already there. But it's also very handy as a command line option, particularly when installation can be slow (like down here in AU where the latency kills us).

j1k commented May 4, 2012

ws@0.4.14 install C:\Program Files\nodejs\node_modules\npm\node_modules\socket
node install.js

npm ERR! Error: spawn ENOTSUP
npm ERR! at errnoException (child_process.js:483:11)
npm ERR! at ChildProcess.spawn (child_process.js:446:11)
npm ERR! at Object.spawn (child_process.js:342:9)
npm ERR! at spawn (C:\Program Files\nodejs\node_modules\npm\lib\utils\exec.j
npm ERR! at exec (C:\Program Files\nodejs\node_modules\npm\lib\utils\exec.js
npm ERR! at Array.0 (C:\Program Files\nodejs\node_modules\npm\lib\utils\life
npm ERR! at EventEmitter._tickCallback (node.js:192:40)
npm ERR! You may report this log at:
npm ERR! http://github.com/isaacs/npm/issues
npm ERR! or email it to:
npm ERR! npm-@googlegroups.com
npm ERR!
npm ERR! System Windows_NT 6.1.7600
npm ERR! command "C:\Program Files\nodejs\\node.exe" "C:\Program Files\nod
ejs\node_modules\npm\bin\npm-cli.js" "install" "socket.io"
npm ERR! cwd C:\Program Files\nodejs\node_modules\npm\node_modules
npm ERR! node -v v0.6.16
npm ERR! npm -v 1.1.19
npm ERR! syscall spawn
npm ERR! code ENOTSUP
npm ERR! message spawn ENOTSUP
npm ERR! errno {}
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! C:\Program Files\nodejs\node_modules\npm\node_modules\npm-debug.log

npm not ok

C:\Program Files\nodejs\node_modules\npm\node_modules>


ke? is this using my --skip-installed implementation or are you just posting a random fail here?

tf commented May 10, 2012


This would be a great addition. I already pulled this into my personal npm fork, and it works well.


hahaha. +1 random fail post.

@rvagg rvagg closed this Nov 7, 2012

@rvagg did you drop this request because you don't think it should be in NPM anymore? this seems quite useful and am considering doing like @tf and pulling into a fork...


@eleith I just get a little OCD about pull-requests that are left open too long, particularly when the codebase moves as fast as npm does; if the changes aren't wanted then I don't need them hanging around in my Pull Requests tab, that's all. Also, we've worked around it in Ender.

The branch is still there @ https://github.com/rvagg/npm/tree/skip-installed but it's kind of old now and I'm not sure how well the commits will apply to the current master.

If you get a hint from @isaacs that this may have a chance I could probably resurrect it and submit a new PR, alternatively you're welcome to steal the code and craft your own PR.

@isaacs isaacs reopened this Dec 7, 2012
npm member

This actually looks fine. I think it just fell through the cracks.

The only thing it needs is to move the config definition to https://github.com/isaacs/npmconf and add it to the documentation at doc/cli/config.md.

@eleith eleith referenced this pull request in npm/npmconf Dec 12, 2012

skip-installed configuration options #7


as requested, changes to npmconf are in this pull request: npm/npmconf#7

also, @rvagg mentioned he might tidy up the branch a bit.

thanks everyone!


Rebased to current master, working great. Ready for review and merge if you want this @isaacs

And, as @eleith said, it depends on npm/npmconf#7


@isaacs do you think this work could get into the next release of npm?




i still have hope for this!


any point rebasing to keep this updated?

@rvagg rvagg closed this May 21, 2013
@luk- luk- reopened this May 21, 2013

@isaacs any thoughts on this?


Talked to @rvagg about it, he doesn't need this anymore. Going to close it to clean up, but we can reopen it if someone wants to work on it.

@luk- luk- closed this Jun 10, 2013

This would be a great feature to have. I'm setting up a Continuous Integration build that will run every time somebody commits to our repo. It would really speed things up if we didn't have to re-download all the dependencies for every build.

npm member

If anyone wants to revive this:

  1. skip-installed should be a [Boolean, null] option. That should be a pull req to npmconf.
  2. If skip-installed is null then it defaults to false for npm install blerg and defaults to true for npm install <noargs>.
  3. I'm not in love with the name. It ends up being a yes to not do the thing kind of thing, which leads to the sort of confusion I just wrote before editing this comment :)

I'm happy keeping this open as long as someone is still hoping for it. It's not a bad idea at all.

@isaacs isaacs reopened this Jul 27, 2013

I don't think that anyone will be me, I don't have a great need for this any more. Whoever wants this, you're more than welcome to steal my code and make it your own, where it still works. @eleith do you still need this?


Maybe a better name for the flag would be --reinstall or force-reinstall. The skip-install flag may lead to double-negatives which can get confusing ie skipInstalled=false means don't skip.

I think the --reinstall flag should default to false as there is no need to install a package if it is already installed. I think that is how maven behaves. This flag would generally be used if somebody suspects a module has been corrupted.

I'd love to get this feature included as it will make our continuous integration build a lot quicker as it will cut down on a lot of unnecessary downloads.


i like @KevinSheedy proposal for naming. @isaacs do you approve?

i'm very much interested in this for the same reason as kevin, due to continue integration tools. i believe whatever changes we do to this branch will also have to happen here to:


i could take a stab at it, once the naming/approach is confirmed to be the right direction.



This thread kinda discourages working on this, as at least 2 good pull requests have just gone stale at this point for no reason. Could really use it though, doing a full reinstall of, say, a bunch of grunt dev packages during a 4 step CI build eats about 20 minutes, lame.

npm member

@juniorplenty we're doing our best here. if you create a pull request that you're willing to maintain, we're willing to take it. The OP's pull request is stale but if you're willing to take it on we'll make it happen.


not good enough @domenic

You're Fired!


get back to work


@domenic - not sure if you've read this thread, but I was referring to the fact that there have been no less than three pull requests that add this option, maintained for months at a time, the first of which was posted to this thread almost a /year/ ago by @rvagg. The @isaacs opened it back up and said it was fine, but needed tweaks, so @eleith made them, issued another pull request, which @rvagg merged and re-posted /8 months/ ago, and maintained for over 4 months, but was for some reason it was never accepted so he eventually abandoned it.

The whole "hey, submit a pull request!" retort kinda loses its muscle if the PR's are going to be ignored.


Can I add to this to say that I've just had to use config management hackery to get around npm not being able to tell if a package is already installed - basic package management to be honest chaps.


I'd like this feature.




This feature would certainly clean up and speed up the Chef recipes we've written to deploy our node apps. Definitely would love to have this in npm. All of the +1's.


i've made a PR #4010 to address the many comments and gifs on this thread. @domenic @isaacs i'm willing to see this through if i could get some advice on what needs to be done to get the PR accepted


i also suggest this PR be closed

@rvagg rvagg closed this Dec 24, 2014


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment