In this article, we would like to show you how to update all dependencies to the latest version in Node.js.
npm update "package-name"
1. Update all dependencies
1. Check if there are dependencies that are out of date.
If there are any outdated dependencies, they will be listed out.
2. Update all dependencies.
This will update the packages in the node_modules folder. The package.json and package-lock.json files will be updated too.
3. If you don’t want to update all packages, you can specify the package names you want to update at the end of the command.
npm update "dotenv"
2. Update all dependencies with major changes
In this example, we present how to update dependencies when there has been a major version change.
1. Check the changelog of the package for breaking changes that could affect your application.
2. If it's safe to update, run the following command:
npm install <packagename>@latest
npm install dotenv@latest
3. Verify if the app isn’t broken and repeat the process for other packages where there is a major version change.
3. Alternative solution
1. Check for updates using
npx npm-check-updates -u
This command will check for updates for all of the dependencies including major version changes in the
2. If you agree for the updates run the following command: