Skip to main content
Third-party libraries let you add complex features without writing everything from scratch. This page teaches you how to evaluate packages for quality and safety, install and organize them correctly, understand semantic versioning, and keep your dependencies secure over time.

Why Use Third-Party Libraries

Every dependency you add is code you did not write but must trust. Always evaluate before installing.

How to Evaluate a Package

Check these indicators before running npm install:
Typosquatting: attackers publish packages named expres, bcrpyt, or mongoos to trick developers. Always verify the exact spelling from official documentation.

Essential Backend Libraries

Memorize this table. These are tested in exams.

Installing Packages

package.json vs package-lock.json

package-lock.json ensures every developer and every deployment gets exactly the same versions. Never delete it.

Semantic Versioning (Semver)

npm packages use MAJOR.MINOR.PATCH:

Version Prefixes in package.json

Security and Maintenance

npm audit

Check and Update Packages

Full Example: Express + cors + helmet

Key Terms

Common Mistakes

node_modules is large, platform-specific, and regenerable. Always add it to .gitignore. Only commit package.json and package-lock.json.
High-severity vulnerabilities can expose your entire application. Run npm audit in your CI pipeline and fail the build on critical findings.
If bcrypt is in devDependencies, it won’t be installed in production with npm install --production and your app will crash. Double check —save-dev vs regular install.
Forced fixes can upgrade major versions with breaking changes. Always run your test suite after force-fixing.