npm / npm/rfcs

[RRFC] Disallow external dependencies on the npm registry

Open
#843 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
777
Forks
267
PR merge metrics
No merged PRs in 30d

Description

Motivation ("The Why")

Package on the npm registry should not be allowed to have "External Dependencies" (i.e. a dependency that is not hosted on the npm registry) because such dependencies do not have the same properties as npm-hosted packages while being nearly invisible to the end user.

For further reference:

Example

There are two big reasons that motivate this change:

  1. The external dependency may become unavailable. Unlike npm, which largely ensures (used) packages don't just disappear, external dependencies do not have that guarantee.
  2. The external dependency may be changed. Unlike npm, which guarantees that published packages are immutable, external dependencies may be changed at any time. Now, some ways of specifying (e.g. by git commit sha(?)) could be argued to provide sufficient integrity guarantees, but otherwise it requires a lockfile. This is inconsistent with "normal" usage of the npm registry and can break security expectations of users.
  3. [ADDED 2026-02-23] The external dependency may be configured in a way that enables arbitrary code execution on the client side.
How
Current Behaviour

External dependencies are allowed.

Desired Behaviour

Any new package published to the npm registry should be checked for external dependencies and if any are found the publication should be rejected. This should only apply to new publications so as to avoid breaking existing deployments. The npm CLI should consider adding a warning when an external dependency appears in the dependency hierarchy as a "mitigation" for the historical baggage of this feature.

A grace period is probably in order during which attempted publications of packages with external dependencies are not flat out rejected, but the client is only warned about upcoming changes.

References

none

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the npm registry publication flow and the npm CLI dependency hierarchy behavior described in the issue. Determine how new publications are distinguished from existing packages, how external dependencies are identified, and what validation, warning, or rejection behavior would satisfy the proposed grace period.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
release, security, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.