-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: Imports fail in flat config file when ESLint installed elsewhere #18465
Comments
As the issue template says, we can't investigate any bug reports without a repro case. If you can please create a StackBlitz showing this behavior we can take a look. |
Link: https://stackblitz.com/edit/stackblitz-starters-jycfg3?file=eslint.config.js Screenshot of repro on stackblitz: |
Ah okay, I see what's happening. Yes, you still need to install |
@nzakas, I have hit this issue as well when trying to use Is there some way to tell It seems that eslint used to take a Thank you! |
@nzakas I tried this again and confirmed that https://github.com/sritchie/eslint-repro Here are the details, also in the repro README. (The implicit question here is, is this
In the repro,
This will install a node environment with the listed "additional dependencies" I used a shell script here, However, when I either run the script explicitly:
Or run it through
I see the following output:
telling me that I would have expected that this
|
Environment
Node version: v20.12.0
npm version: 10.8.0
Local ESLint version: v9.2.0
Global ESLint version: n/a
Operating System: macOS
What parser are you using?
Default (Espree)
What did you do?
An empty directory with just this
eslint.config.js
:Run the CLI with npx as documented:
$ npx eslint
What did you expect to happen?
The
require
/import
statements resolve.@eslint/js
is installed with ESLint:eslint/package.json
Line 72 in 06f1d1c
What actually happened?
Crash:
The way ESLint loads the config file means that its import statements aren’t resolved.
(The bug also occurs with ESM config in
eslint.config.mjs
, with a slightly different error message:Cannot find package '@eslint/js' imported from /Users/chainz/tmp/test-eslint/eslint.config.mjs
.)Link to Minimal Reproducible Example
Open https://stackblitz.com/edit/stackblitz-starters-jycfg3?file=eslint.config.js and run
npx eslint
:Participation
Additional comments
It seems that to use flat config, you must install ESLint in the same directory as configuration? If so, that really breaks using tool managers—I found this out when using ESLint under pre-commit, which manages tools in its own directory outside of your project.
The text was updated successfully, but these errors were encountered: