Shula
Shula

Reputation: 306

Can npm-update and npm-install give different result?

Let's say we have 3 packages with the following dependencies:

C -> B@^1.0.0 and B -> A@^1.0.0

(module C depends only on module B version 1.0.0 and above; module B depends on module A version 1.0.0 and above;)

Now I'm doing the following steps:

  1. npm-install in module C (result: node_modules contains A@^1.0.0 and B@^1.0.0)
  2. npm-publish of higher version of module A: A@^1.0.1
  3. npm-update in module C (result: node_modules contains A@^1.0.0 and B@^1.0.0) --- A module didn't changed!

But, if i'm cleaning node_modules and then npm-install module C again, i'm getting that node_modules contains A@^1.0.1 and B@^1.0.0

Upvotes: 1

Views: 144

Answers (1)

Benjamin Gruenbaum
Benjamin Gruenbaum

Reputation: 276306

npm update respects semantic versioning, it will not update major versions of packages if you have a ^ dependency.

^ on a dependency literally means that it's only fine to update up to a minor version - since major versions contain breaking changes.

This command will update all the packages listed to the latest version (specified by the tag config), respecting semver.

From the docs

Upvotes: 0

Related Questions