|
|
|
|
|
by IsaacSchlueter
2663 days ago
|
|
That is incorrect. Both `npm install` and `npm ci` respect the lock file, and if a lock file is present, will make the `node_modules` tree match the lock file exactly. `npm ci` is optimized for a cold start, like on a CI server, where it's expected that `node_modules` will not be present. So, it doesn't bother looking in `node_modules` to see what's already installed. So, _in that cold start case_, it's faster, but if you have a mostly-full and up to date `node_modules` folder, then `npm install` may be faster, because it won't download things unnecessarily. Another difference is that `npm ci` also won't work _without_ a `package-lock.json` file, which means it doesn't even bother to look at your `package.json` dependencies. |
|
For example, why did this person experience the changing lockfile? https://github.com/npm/npm/issues/17101
Or why do these docs say?
> Whenever you run npm install, npm generates or updates your package lock https://docs.npmjs.com/files/package-locks
Oh, this seems like what I experienced: https://stackoverflow.com/a/45566871/283398
It does appear that npm works somewhat differently than the “obvious” way we would expect package managers to work vis a vis lockfiles :(
At least npm ci gets the job done for my use case :)