Install --save does not move a previously installed package from devDependencies

What I Wanted to Do

I have a previously installed package in devDependencies. When I run npm i --save package, I assumed the package would be moved to dependencies.

What Happened Instead

It did not move it. In this case a new patch version was installed but it remained in devDependencies

Reproduction Steps

npm i --save-dev pacakge
npm i --save package

Details

Platform Info

$ npm --versions                                                                                                                                                        
{
  '@wesleytodd/openapi': '0.0.7',
  npm: '6.10.2',
  ares: '1.15.0',
  brotli: '1.0.7',
  cldr: '35.1',
  http_parser: '2.8.0',
  icu: '64.2',
  llhttp: '1.1.4',
  modules: '72',
  napi: '4',
  nghttp2: '1.39.1',
  node: '12.7.0',
  openssl: '1.1.1c',
  tz: '2019a',
  unicode: '12.1',
  uv: '1.30.1',
  v8: '7.5.288.22-node.16',
  zlib: '1.2.11'
}

$ node -p process.platform
darwin

--save-prod does what you expect.

--save is not listed in the documentation: https://docs.npmjs.com/cli/install

Oh interesting, this is a change. I am guessing this changed with the automatic save behavior (v5?). I wonder if the --save behavior is the old behavior.

1 Like