NPM packages often get new releases (adding new functionalities, fixing bugs or vulnerabilities). It is important to keep the packages updated as much as possible during the development of your application. Learn more on Do you maintain your dependencies?
The best way to do that is to update all the packages every time you add a new package to your application, and include the npm outdated and npm audit reports in the Sprint Review. These commands are also available with yarn with yarn outdated and yarn audit.
# NPMnpm outdatednpm audit# Yarnyarn outdatedyarn audit# PNPMpnpm outdatedpnpm audit
Running npm outdated returns an overview of your packages versions showing:
The packages output from this command will also show up in different colours:
Figure: Use 'npm outdated'
npm audit returns an audit on your packages for vulnerabilities. It also provides information on how to resolve them.
Figure: Use 'npm audit' to discover vulnerabilities in your application
To add a new package, use:
# NPMnpm install package-name# Yarnyarn add package-name# PNPMpnpm add package-name
To update your packages, use:
# NPMnpm update package-name# Yarnyarn upgrade package-name# PNPMpnpm update package-name
Yarn also has a useful tool called yarn upgrade-interactive that allows you to see which packages are outdated, and upgrade them all at once.
Figure: Using yarn upgrade-interactive
Note: Use yarn upgrade-interactive --latest to see outdated packages with breaking changes.