-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
ESLint error: Cannot read property 'externals' of undefined #1448
Comments
Where’s your webpack config? What version of webpack do you have? |
|
why is your eslint and webpack config not in the same dir, the root of the project? |
We have another .eslintrc.js in root/. Only what’s in src needs the webpack resolver since everything else we have uses normal Node.js resolution. |
If you copy/move the webpack config into |
If I copy/move the webpack config to Sorry, let me give more context. This bug looks a lot like #1219, which was supposedly fixed, but is still happening when using the latest version of Here's the output from running
From |
Did you ever figure out the answer to this? Having a similar if not the same issue. |
This issue will happen if, for example, you're missing a Babel plugin. To see what's actually going on, run ESLint with the What should be solved here is the opaque error. It should actually show what really happened, without having to run it with EDIT: This wasn't the underlying issue. The actual issue is here. |
Ok, after looking more into this, the actual issue is that if a webpack config returns an array and neither of the configurations has a This seems to just be a bug with the webpack resolver. A workaround is to add an empty resolver field to your webpack config, i.e., |
I mean, if you're using the webpack resolver, but your webpack config has no resolvers in it, that seems confusing? Why are you using the webpack resolver if webpack isn't changing how it resolves any paths? |
That's a good question. In my case, the ESLint config is at the top-level of a monorepo and is used to lint multiple packages. Some of these packages use webpack, others don't. Of the ones that do, some of them use the |
Makse sense - it seems reasonable for the webpack resolver to be a noop (altho, it should probably log a console warning) when there's no webpack config with a |
Sure! As for the current implementation, do you have any suggestion for making the resolver be a noop? Should I just default it to an empty config in this current error case and log a warning? |
That seems reasonable to me. |
I'm using
I'm trying to add
to my
.eslintrc.js
, as recommended in the readme at https://www.npmjs.com/package/eslint-import-resolver-webpackHowever, running
eslint
is failing withTypeError: Cannot read property 'externals' of undefined
The text was updated successfully, but these errors were encountered: