Join our Newsletter — 33% off our NHI Course
Architecture & Implementation

npm install

← Back to Glossary
By NHI Mgmt Group Updated November 25, 2026 Domain: Architecture & Implementation

npm install is the command that installs a package and its dependencies from the npm ecosystem into a project or global location. It reads package metadata, resolves versions, downloads the package contents, and updates the lockfile or local modules folder when configured to do so.

What npm install actually changes in a project

At a practical level, npm install is a supply-chain action, not just a convenience command. It can change the dependency graph, bring in transitive packages, update lockfiles, and execute package lifecycle scripts, which means it affects both what code enters the project and what code may run during installation.

That makes the command central to build reproducibility and trust. The same command can produce a clean, deterministic install in one environment and a compromised one in another if the registry source, lockfile state, or install-time script policy is weak.

Why npm install is a security boundary

npm install sits at the point where third-party code crosses into your workspace, so it is one of the highest-risk moments in the JavaScript supply chain. Malicious packages, dependency confusion, typosquatting, poisoned transitive dependencies and install-time scripts all exploit the assumption that package installation is routine and therefore safe.

Install-time abuse is especially dangerous because packages may execute before developers notice the content they pulled in. NHIMG’s npm Install-Time Security Guide covers the controls that matter most here, including script allowlists, release-age cooldowns, frozen lockfiles and registry settings.

Recent npm compromises show why this boundary matters: attackers repeatedly target maintainer accounts and publish tokens because one successful publish can distribute malware to many downstream projects. The practical security question is not whether packages are useful, but whether the install process is allowed to trust them by default.

How teams verify what they are installing

Exposure checks start with inventory and provenance. Teams need to know which projects use npm, which registries they pull from, whether the install is driven by a lockfile, and whether the environment allows scripts or mutable version ranges. Without that baseline, it is hard to tell whether a given install is pulling a known dependency or an unexpected one.

A second check is whether the package ecosystem is being treated as code or as a live feed. Dependency pinning is the main control here, because semver ranges, missing lockfiles and ad hoc updates all increase the chance that an install silently resolves to a different artifact than the one previously reviewed. Dependency Pinning vs Version Ranges explains why exact pins, hash pins and lockfiles provide different levels of assurance.

For high-confidence review, organisations also compare the local install result with vendor advisories and package history. The key is to verify the package identity, not just the package name, because attackers often rely on trust in familiar names, popular maintainers or automated update flows.

Remediation, detection and post-install review

If you suspect a malicious or unexpected install, the response is broader than deleting node_modules. Teams should assume that package scripts may have run, credentials may have been exposed, and the lockfile may now reflect a compromised dependency set. In practice, the remediation goal is to restore a trusted dependency baseline and check whether the install touched any secret-bearing environment.

Detection should look for unusual install-time network calls, new postinstall activity, unexpected package version changes and new files or tokens created during the install window. If the package touched developer tokens, CI credentials or cloud secrets, those secrets should be treated as potentially exposed and rotated according to their scope and blast radius.

Post-patch review matters because malicious packages can leave behind persistence in build systems, caches or dependency caches even after the obvious artifact is removed. For that reason, organisations should review the install event as an intrusion path, not just a software update failure.

Safer ways to use npm install in practice

The safest operational pattern is to make installation as deterministic and restrictive as the workflow allows. That usually means preferring locked, reviewable installs over free-form resolution, limiting lifecycle scripts where possible, and making registry and provenance choices explicit instead of inherited from developer machines.

When teams need broader install flexibility, they should still separate trusted dependency updates from untrusted first-time resolution. The goal is to reduce surprise, because surprise is where most package-chain compromise gets leverage.

In mature environments, the command is governed as part of software supply-chain policy, not left as a developer preference. That framing helps teams decide who can change dependencies, which sources are acceptable, and what evidence is required before a package is allowed into the build.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP Non-Human Identity Top 10 addresses the attack and risk surface, while CIS Controls v8 and NIST SP 800-53 Rev 5 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
CIS Controls v8CIS-16 — Application Software Securitynpm install governs software ingestion and build-time trust.
Recommendation — Restrict package installation sources and review dependencies before allowing them into builds.
NIST SP 800-53 Rev 5SA-12 — Supply Chain Protectionnpm install introduces third-party package supply-chain risk.
CM-7 — Least FunctionalityInstall-time scripts and broad dependency pulls expand runtime exposure.
Recommendation — Apply supply-chain protections to verify package provenance and integrity before installation. Limit install-time functionality by blocking unnecessary scripts and package actions.
OWASP Non-Human Identity Top 10NHI-02 — Secret Leakagenpm installs often expose or exfiltrate tokens, keys and credentials.
NHI-07 — Long-Lived SecretsCompromised npm workflows frequently abuse persistent publish tokens.
Recommendation — Scan install paths for secret leakage and rotate any exposed credentials immediately. Shorten secret lifetime for package publishing and rotate tokens after suspicious installs.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Reviewed and updated by the NHIMG editorial team on November 25, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org