loopbackio / loopbackio/loopback-next
@loopback/build: `lb-eslint` throws "Package subpath './bin/eslint' is not defined by 'exports'" when in npm workspaces environment
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5.1k
- Forks
- 1.1k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 27
Description
### Describe the bug
Running `lb-eslint` command from a package in npm workspaces environment throws following error:
Full Command: `lb-eslint --report-unused-disable-directives .`
```
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './bin/eslint' is not defined by "exports" in /Users/shubham.prajapat/repos/my-mono-repo/node_modules/eslint/package.json
```
### Logs
```shell
loopback:build /Users/shubham.prajapat/repos/sourcefuse/loopback4-microservice-catalog/packages/cache/.eslintrc.js found +0ms
loopback:build /Users/shubham.prajapat/repos/sourcefuse/loopback4-microservice-catalog/packages/cache/.eslintignore found +1ms
loopback:build Trying to resolve CLI module 'eslint' from /Users/shubham.prajapat/repos/sourcefuse/loopback4-microservice-catalog/packages/cache +0ms
loopback:build CLI module 'eslint' is not found in dependencies +0ms
node:internal/modules/cjs/loader:571
throw e;
^
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './bin/eslint' is not defined by "exports" in /Users/shubham.prajapat/repos/sourcefuse/loopback4-microservice-catalog/node_modules/eslint/package.json
at new NodeError (node:internal/errors:399:5)
at exportsNotFound (node:internal/modules/esm/resolve:361:10)
at packageExportsResolve (node:internal/modules/esm/resolve:697:9)
at resolveExports (node:internal/modules/cjs/loader:565:36)
at Module._findPath (node:internal/modules/cjs/loader:634:31)
at Module._resolveFilename (node:internal/modules/cjs/loader:1061:27)
at Function.resolve (node:internal/modules/cjs/helpers:116:19)
at resolveCLI (/Users/shubham.prajapat/repos/sourcefuse/loopback4-microservice-catalog/node_modules/@loopback/build/bin/utils.js:76:18)
at Object.runCLI (/Users/shubham.prajapat/repos/sourcefuse/loopback4-microservice-catalog/node_modules/@loopback/build/bin/utils.js:128:9)
at run (/Users/shubham.prajapat/repos/sourcefuse/loopback4-microservice-catalog/node_modules/@loopback/build/bin/run-eslint.js:45:16) {
code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}
Node.js v18.16.0
```
### Additional information
### Reproduction
https://codesandbox.io/p/github/shubhamp-sf/eslint-17321-reproduction/main
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with @loopback/build/bin/utils.js, especially resolveCLI, and bin/run-eslint.js, which appear in the stack trace. Run `lb-eslint --report-unused-disable-directives .` in the linked npm-workspaces reproduction and inspect how the CLI module is resolved. Done means the command runs successfully in that workspace setup without the ERR_PACKAGE_PATH_NOT_EXPORTED failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- eslint, nodejs, typescript
- Domain
- build-system, cli, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100