Interview frequency: …
Short answer
Use npm audit, pin exact versions, enable --ignore-scripts, scan dependencies with static analysis tools, and rely on a trusted lockfile.
Explanation
npm packages are a major target for attackers through Typosquatting or malicious code in installation scripts (postinstall hooks). Protection includes running automated security scans in CI, blocking untrusted scripts with --ignore-scripts, and enabling package signature verification (npm provenance).
Code example
npm audit --audit-level=high
npm ci --ignore-scriptsCommon mistakes
- Installing unknown packages with few downloads without reviewing their source code and license.