npm packages let you reuse existing libraries instead of rebuilding common functionality.
Before adding a package, consider its maintenance, security, license, size, and whether the dependency is actually necessary.
Deep dive
Understand node_modules
Installed packages are normally placed under node_modules. This directory is usually not committed to Git because dependencies can be recreated from package metadata and the lock file.
Useful commands
- npm install: install project dependencies.
- npm install package: add a dependency.
- npm uninstall package: remove a dependency.
- npm update: update dependencies according to package rules.
- npm audit: inspect reported dependency vulnerabilities.