1

I use npm ci to install npm modules and it install same package versions as in package-lock.json

And now I need to add npm module for starting write unit tests, I use this command: npm i jest

I expect that it should add only jest dependencies, but npm update all out-of-date dependencies of 3-5 level dependencies in package-lock.json

I would like to do something like this npm ci --save-dev jest

How to install npm package without changing old dependencies in package-lock.json?

UPD For example, please clone this repo, after that use npm ci and npm i empty-module, if you look at git diff you'll see a lot of changes of package-lock.json file

Yegor
  • 3,652
  • 4
  • 22
  • 44
  • 1
    Possible duplicate of [Why does "npm install" rewrite package-lock.json?](https://stackoverflow.com/questions/45022048/why-does-npm-install-rewrite-package-lock-json) – Victor Noël Jul 23 '19 at 09:29
  • not sure, I asked about how to add dep without changing whole `package-lock.json`, not about `npm install` command, but I guess its impossible(but I'm not sure), if so, I'll accept it – Yegor Jul 23 '19 at 09:45
  • yes it seems it's not possible directly with npm, so maybe the only solution is to specify non-wildcard versions in package.json? I'm not sure then :) – Victor Noël Jul 24 '19 at 12:13
  • Are you sure it updates all the dependencies? I rather expect it to update *shared* dependencies of your dependency (and their dependencies). [jest has a lot of dependencies](https://github.com/facebook/jest/blob/master/package.json), so I expect the changes to the lockfile to be significant. – k0pernikus Jul 26 '19 at 12:11
  • See this reference point: An single install of jest will introduce over 4,000 lines of lock file: https://gist.github.com/k0pernikus/80173415337931e5132616b0628c041c – k0pernikus Jul 26 '19 at 12:16
  • @k0pernikus Yeah, I checked it with `empty-module` (https://www.npmjs.com/package/empty-module), and it updated some old deps too, I'll add repro to my question in 48h – Yegor Jul 26 '19 at 12:52

0 Answers0