npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

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


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: '',
  zlib: '1.2.11'

$ node -p process.platform

--save-prod does what you expect.

--save is not listed in the documentation:

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.