Making npm update respond to the --dev flag in the same way that npm install currently does would be useful from a development point of view. This is really to do with speeding up multiple invocations of npm test.
As an example the following package.json requires the vows package to be present for running the tests. The presence of the pretest key ensures that running npm test works as expected as vows will be installed. However, vows is installed every time npm test is run:
"pretest": "npm install vows",
"test": "./node_modules/.bin/vows --spec ./test/mytest.js"
The process could be streamlined if the value for pretest could be replaced with npm --dev true update: vows would only be installed the first time npm test was run, speeding up subsequent invocations of npm test.
npm --dev true update
Alternatively perhaps npm test could do an implicit check and install of devDependencies although that would be definitively tying devDependencies to npm test: devDepencencies might only be used for non test related things like documentation.
This could be solved by forcing npm test do an explicit check of devDependencies by making it aware of --dev in the same way as npm install currently is.
@homme are you this still having this issue? npm update now does update devDependencies if you pass --dev.
But I'm not sure that's the core of your issue here.
The current state of affairs is thus:
when npm install is run inside a module directory, unless the --production flag is also passed, it will always install development dependencies for the current package, (but not any of the modules in node_modules).
So in your case, you shouldn't need the pretest script at all, vows should just be installed.
In addition, you don't need the ./node_modules/.bin/' to callvows, all npm scripts get that automatically added to their$PATH`.
./node_modules/.bin/' to call
, all npm scripts get that automatically added to their
Your package.json should work just fine like so:
"test": "vows --spec test/mytest.js"
Clean up npm test invocation
This implements the suggestions at
@timoxley many thanks for the update and explanation: I've implemented your suggestions and everything seems to run perfectly!