Skip to content

[BUG] allow-git=root does not allow root level git dependencies to be installed #9189

@akhenry

Description

@akhenry

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

The allow-git=root option refuses to install root-level git dependencies.

Expected Behavior

allow-git=root should install root-level git dependencies but refuse to install transitive git dependencies, per the documentation:

root only allows git dependencies defined in your project's package.json to be fetched installed.

Steps To Reproduce

  1. Create a simple package.json with a root dependency on a git project
cat > package.json.text <<- EOF
{
  "dependencies": {
    "left-pad": "github:left-pad/left-pad"
  }
}
EOF
  1. Attempt to install with --allow-git=root
npm install --allow-git=root
  1. Observe the following error:
$ npm install --allow-git=root
npm error code EALLOWGIT
npm error Fetching non-root packages of type "git" have been disabled
npm error Refusing to fetch "left-pad@github:left-pad/left-pad"
npm error A complete log of this run can be found in: 

Environment

  • npm: 11.12.1
  • Node.js: v25.9.0
  • OS Name: Mac OS 15.7.4 (24G517)
  • System Model Name:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingNeeds Triageneeds review for next steps

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions