Current Behavior
When using npm workspaces with multiple Nx workspace roots (each child workspace has its own nx.json), the @nx/dependency-checks ESLint rule reports all dependencies as unused. Every dependency in every library's
package.json gets flagged with "<package>" is not used.
Expected Behavior
@nx/dependency-checks should be able to resolve npm dependencies against the lockfile even when the Nx workspace root differs from the npm workspace root (i.e., the lockfile lives in a parent directory).
GitHub Repo
No response
Steps to Reproduce
- Create a monorepo with npm workspaces
- Add
nx.json to a child workspace (e.g., frontend/lit/nx.json)
- Enable
@nx/dependency-checks in that child workspace's ESLint config
- Run ESLint from the child workspace:
cd frontend/lit && npx eslint libs/my-lib/package.json
- All dependencies are reported as unused
├── package.json ← workspaces: ["frontend/lit", "frontend/app"]
├── package-lock.json ← single lockfile for all workspaces
├── nx.json ← root Nx workspace (optional)
│
└── frontend/lit/ ← npm workspace child
├── nx.json ← nested Nx workspace root
├── package.json
├── .eslintrc.json ← enables @nx/dependency-checks
└── libs/
└── my-lib/
├── package.json ← declares dependencies (lit, rxjs, etc.)
└── src/
└── index.ts ← imports lit, rxjs, etc.```
### Nx Report
```shell
NX Report complete - copy this into the issue template
Node : 22.22.2
OS : linux-x64
Native Target : x86_64-linux
npm : 10.9.7
nx : 21.6.10
@nx/js : 21.6.10
@nx/jest : 21.6.10
@nx/eslint : 21.6.10
@nx/workspace : 21.6.10
@nx/angular : 21.6.10
@nx/cypress : 21.6.10
@nx/devkit : 21.6.10
@nx/eslint-plugin : 21.6.10
@nx/module-federation : 21.6.10
@nx/playwright : 21.6.10
@nx/plugin : 21.6.10
@nx/storybook : 21.6.10
@nx/vite : 21.6.10
@nx/web : 21.6.10
@nx/webpack : 21.6.10
typescript : 5.9.3
---------------------------------------
Cache Usage: 0.00 B / 100.69 GB
Failure Logs
Package Manager Version
npm --version 10.9.7
Operating System
Additional Information
No response
Current Behavior
When using npm workspaces with multiple Nx workspace roots (each child workspace has its own
nx.json), the@nx/dependency-checksESLint rule reports all dependencies as unused. Every dependency in every library'spackage.jsongets flagged with"<package>" is not used.Expected Behavior
@nx/dependency-checksshould be able to resolve npm dependencies against the lockfile even when the Nx workspace root differs from the npm workspace root (i.e., the lockfile lives in a parent directory).GitHub Repo
No response
Steps to Reproduce
nx.jsonto a child workspace (e.g.,frontend/lit/nx.json)@nx/dependency-checksin that child workspace's ESLint configcd frontend/lit && npx eslint libs/my-lib/package.jsonFailure Logs
Package Manager Version
npm --version 10.9.7
Operating System
Additional Information
No response