`save` option has no effect in npm >=5
aduth opened this issue · comments
The implementation of the save
option works by appending a --save
flag if the option is provided, otherwise just calling npm install ...
:
Unfortunately, this doesn't work after npm 5, which changed the default behavior of npm install
to save by default:
npm will --save by default now
https://blog.npmjs.org/post/161081169345/v500
Thus, regardless if save
option is passed as true
or false
or omitted altogether, it will always effect the save behavior.
Seems like a fix may just be to invert the condition for passing --no-save
:
const args = ['npm', 'install', name]
if (opts.save !== true) {
args.push('--no-save')
opts.save = null // {delete opts.save} is very slow
}
Reference: https://docs.npmjs.com/cli/install
Not sure if there's backward-compatibility commitment to consider here, i.e. supporting Node < 5, where the default behavior would be different. In which case, I suppose it may be required to always pass a flag depending on the setting:
const args = ['npm', 'install', name, opts.save ? '--save' : '--no-save']
Lgtm, will resolve tomorrow