-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Description
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
npm query ':root > *' --install-strategy=linked returns incorrect results:
- Transitive dependencies appear as direct children of root (e.g.
abbrevwhich is only a dependency ofnopt, not a root dependency). - Bare store directory nodes without a name appear in results (e.g.
node_modules/.store/nopt@7.2.1-...with nonamefield). - The total number of results is higher than the actual number of direct dependencies.
This affects both workspace and non-workspace projects. With the hoisted strategy, :root > * correctly returns only direct dependencies.
Expected Behavior
npm query ':root > *' should return only the direct dependencies declared in package.json. For the example below with nopt, ini, and semver as direct deps, it should return exactly 3 entries.
Steps To Reproduce
- Create a project:
mkdir test-query && cd test-query
cat > package.json << 'EOF'
{
"name": "test-query",
"version": "1.0.0",
"dependencies": { "nopt": "^7.0.0", "ini": "^4.0.0" },
"devDependencies": { "semver": "^7.0.0" }
}
EOF- Install and query:
npm install --install-strategy=linked
npm query ':root > *' --install-strategy=linked- Returns 5 entries instead of 3. Extracting name and location:
name=abbrev, location=node_modules/.store/abbrev@2.0.0-.../node_modules/abbrev
name=ini, location=node_modules/.store/ini@4.1.3-.../node_modules/ini
name=?, location=node_modules/.store/nopt@7.2.1-...
name=semver, location=node_modules/.store/semver@7.7.4-.../node_modules/semver
name=nopt, location=node_modules/.store/nopt@7.2.1-.../node_modules/nopt
abbrevis a transitive dep ofnopt, not a root dep — should not appear.- The entry at
node_modules/.store/nopt@7.2.1-...has no name — this is a bare store directory node leaking into results.
Environment
- npm: 11.11.0
- Node.js: v22.20.0
- OS Name: macOS (Darwin 25.3.0)
- System Model Name: Mac
- npm config:
install-strategy=linkedReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels