npm i -g npm-check-updates
ncu -u
npm install
To update each dependency in your package.json to the latest version, you have a few options depending on your workflow and how aggressive you want the updates to be.
You can use the npm-check-updates tool:
# Install globally if not already installed
npm install -g npm-check-updates
# Check for latest versions
ncu
# Upgrade package.json dependencies to the latest versions
ncu -u
# Install updated dependencies
npm install
npm Commands# This updates packages to the latest **compatible** versions based on the existing semver ranges.
npm update
If you want to update to the absolute latest versions (possibly including breaking changes), you'll need to change the version ranges in package.json manually or use ncu as above.
package.jsonYou can directly change each version to:
"some-package": "latest"
Or even:
"some-package": "^latest_version"
Then run:
npm install
This is not recommended for large projects unless you know exactly what you're updating, as it can introduce breaking changes.
After updating, always:
package-lock.json or yarn.lock).