Skip to content

[RRFC] Disallow external dependencies on the npm registry #843

Open

Description

@ericcornelissen

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

Activity

  1. ericcornelissen commented on Nov 21, 2025

    @ericcornelissen
    Author

    Any new package published to the npm registry should be checked for external dependencies and if any are found the publication should be rejected.

    I believe it should be okay to allow external "devDependencies".

  2. ericcornelissen commented on Feb 23, 2026

    @ericcornelissen
    Author

    The --allow-git=none option addresses this from the consumer side, I still think it makes sense to address this from the registry side as well. This would make it easier for consumers to use --allow-git=none as sticking with the npm registry would virtually guarantee the option doesn't have to be disabled and also prevent "mistakes"/"accidents" from package producers.

    Moreover, the linked blog post gives another motivation for this change: the ability the perform arbitrary command execution through git dependencies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions