Skip to content
This repository has been archived by the owner on Jan 25, 2023. It is now read-only.

Switch to npm ci #513

Closed
wants to merge 4 commits into from
Closed

Conversation

denis-sokolov
Copy link

@denis-sokolov denis-sokolov commented Dec 21, 2020

npm install is somewhat meant for interactive runs. Here are some reasons to avoid it:

npm ci is meant for automated deployments and does not suffer from the same issues. Instead, it manages its own cache (#511) and ensures a deterministic result.

It still is slower than an npm install under ideal conditions, but it might be less of a concern than previously expected. With the npm cache (#511), an npm ci on a mid-size project on a laptop takes 7-8s for me as opposed to 2-3s for npm install. The command also runs offline, retrieving all packages from the cache.

This PR might be breaking for some user-provided NPM_FLAGS. As npm ci does not take any options, we may be disabling some functionality users expected. An overview of the existing npm install options brings these, probably unlikely, cases:

  • Users with --dry-run and package-lock.json will suddenly have their dependencies installed. Assuming they also install their dependencies themselves in a separate step, this will not impact their build success, but will slow it down by adding duplicate effort;
  • Users with --no-package-lock will get older versions of dependencies than they expect, likely breaking their builds;
  • Users with --omit will get more dependencies than they expect, probably not impacting their build success, but slowing it down;
  • Users with --ignore-scripts may have their builds slow down or possibly break.

Closes #113, #114, #165, #172, #509, #510, #511.

npm install is optimized for the development process and if node_modules is in a correct state,
npm install will quit quickly after checking the status of the cache.

Removing the conditional will prevent breakages related to stale cache.
@denis-sokolov denis-sokolov requested a review from a team as a code owner December 21, 2020 07:32
@JGAntunes JGAntunes added init/monorepo-support type: feature code contributing to the implementation of a feature and/or user facing functionality labels Feb 24, 2021
@kaufmo kaufmo mentioned this pull request Mar 3, 2021
@kitop
Copy link
Contributor

kitop commented Aug 24, 2022

Closing this PR as it's against xenial branch and the Xenial image is going to be deprecated: https://answers.netlify.com/t/please-read-end-of-support-for-xenial-build-image-everything-you-need-to-know/68239

Feel free to reopen against focal.

@kitop kitop closed this Aug 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
init/monorepo-support type: feature code contributing to the implementation of a feature and/or user facing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

treat package-lock.json the same way we treat package.json if checksum changes
3 participants