Managing dependencies is very important to developing and maintaining a JavaScript application. Here are three quick tips to help with checking for missing, unused, or out-of-date dependencies!
Want to check a project for dependencies missing from the package.json?
Use depcheck!
Install the Depcheck
tool to analyze JavaScript projects for dependencies missing from the package.json
.
- Any
npm
packages that are missing from thepackage.json
file and the associated JavaScript file path where the package is used are listed. The packages can then be installed using the npm-install command.
Want to check a project for unused dependencies?
Use depcheck!
Depcheck
also analyzes JavaScript projects for unused dependencies.
- The unused
npm
packages are listed and it is safe to remove these from the project by running the npm-uninstall command.
Want check a project for out-of-date dependencies?
Use npm-outdated!
This command will check the registry and compare with the versions specified in the package.json
file. Simply run the command npm outdated
in the same directory as the project package.json
.
Given this package.json
:
{
"@material-ui/core": "^4.10.0",
"@okta/okta-react": "1.1.4",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"axios": "^0.19.2"
}
Here is the npm outdated
output:
Red
means update now -> A newer version is available matching the specifiedpackage.json
version so this should be updated now.Yellow
means use caution -> A newer version is available above the specifiedpackage.json
version. Make sure to test your application with the higher package version to ensure there are no breaking changes introduced when updating.Use the npm-update command to update the dependencies accordingly.
Top comments (0)