Skip to content

Conversation

@tombye
Copy link
Contributor

@tombye tombye commented Sep 17, 2025

What’s changed

Change uses of npm install in the gemspec file to instead use npm ci, to ensure no npm packages used by the gem get updated when the gem is installed.

Identifying a user need

Users of the gem should be able to know, and query, which npm packages the gem will install on their machine/environment at any given time. This is easy to do with npm ci, because it just installs what's in package-lock.json from scratch whereas npm install will install whatever npm packages satisfy the versions specified in package.json.

Notes for reviewers

Please check the logic behind these changes, described in the commit message, before approving. These changes make the assumption that the only difference this will make to users of the gem is the lack of any changes to the npm packages in their node_modules folder.

Running `npm install` will change the dependencies
in node_modules and what is listed in
package-lock.json if the dependencies in
package-lock.json don't match the dependency tree
possible for the versions specified in
package.json.

Running `npm ci` deletes node_modules at the start
and installs exactly what's in package-lock.json,
irrelevant of whether any sub-dependencies of the
packages listed in package.json have newer
versions allowed by their semver ranges or not.

A nicer way to explain might be this example:

If the 'standard' package changes by a patch
version and we run `npm install`:
1. its version includes the '^' prefix so allows
  patch and minor version bumps
2. the new version would be installed into node_modules
3. package-lock.json would be updated to reference the new version
4. `npm install` is then run on the new version of
   'standard', checking for the latest versions of
   its dependencies allowed and installing them,
   all the way down the tree

If the 'standard' package changes by a patch
version and we run `npm ci`:
1. the node_modules folder is emptied
2. all the dependencies listed in
   package-lock.json are installed at the versions
   specified

So in the second example, `npm ci` ignores the
new patched version because it only goes by what's
in package-lock.json.

I think we want the later behaviour, because it
splits updates out into a separate step and stops
them happening during gem installation.

References:
- https://docs.npmjs.com/cli/v11/commands/npm-install
- https://docs.npmjs.com/cli/v11/commands/npm-ci
Copy link
Contributor

@kr8n3r kr8n3r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested locally

@tombye tombye merged commit 078b6b9 into main Sep 17, 2025
3 checks passed
@tombye tombye deleted the change-npm-install-method branch September 17, 2025 16:19
tombye added a commit that referenced this pull request Sep 17, 2025
Patch release to change the method of installation
npm uses:

#433
@tombye tombye mentioned this pull request Sep 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants