npm Community Forum (Archive)

The npm community forum has been discontinued.

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

Different save-prefix in package.json for internal registry

Hi :slight_smile:

I have packages from my internal npm registry that I need to be saved in package.json with a ~ prefix, so that only patch updates will apply.

However, the default for public npm dependencies is to have a ^ prefix, so that minor version updates will apply, which I’d like to keep.

I am aware of how to set a save-prefix, but this will apply to all packages, and I can’t seem to find a way to specify a save-prefix for internal packages. This means I need to manually roll back package.json every time npm update is run.

Does anyone have any pointers for me?


Hello, pulling from the npm documentation, to get the old behavior that existed before npm@5.0.0 you can run npm update --no-save. This won’t save the updated version as a required dependency. I tested this on an old repo with npm@6.4.1 and none of the prefixes were changed.

I think it’d be a cool feature to be able to preserve the save-prefixes when running npm update though. Maybe just have something like a --preserve flag? This way the version numbers could still update without modifying the prefixes.