Updating NPM Packages
- Navigate to the root directory of your project and ensure it contains a
package.json
file:cd /path/to/project
- In your project root directory, run the outdated command to view outdated packages:
npm outdated
- In your project root directory, run the update command:
npm update
package.json
The way the wanted version is set in the package.json file may affect how updates are decided.
Version numbers are declared as a [major, minor, patch]
tuple.
Caret Ranges ^1.2.3
Allows changes that do not modify the left-most non-zero element of the version specification. So 1.3.1 will update to 1.3.2 or 1.4.0. Though, 0.3.0 will update to 0.3.1 but not update to 0.4.0.
Version will update if:
- ^1.2.3 : 1.2.3 < version < 2.0.0
- ^0.3.0 : 0.3.0 < version < 0.4.0
X-Ranges
Allows ‘X’, ‘x’, or ‘*’ to stand in for a number in the version specification.
Version will update if:
- “” : any version
- same as “*” or “x.x.x”
- 1.x.x : 1.0.0 < version < 2.0.0
- same as “1”
- 1.2.x : 1.2.0 < version < 1.3.0
- same as “1.2”