-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Unable to resolve path to module 'nanoid' since Webpack 5 #1953
Comments
I've got the same issue with other packages. I use react-hook-form on 3 differents files of my project and I got this error for one of then. 😲 With webpack@4, no issues. |
Temporary fix is add alias to webpack config: resolve: {
alias: {
"apollo-upload-client": path.resolve(__dirname, "..", "node_modules", "apollo-upload-client"),
"react-hook-form": path.resolve(__dirname, "..", "node_modules", "react-hook-form"),
},
} |
webpack 5 unfortunately breaks the ecosystem; you'll need to use ProvidePlugin to ensure it shims node core modules when possible. I'm not sure if that's the issue here; perhaps the webpack resolver needs updating for webpack 5. |
This appears to impact modules that use the new Adding the following to our webpack config did resolve the
|
@Cherry hm, the node resolver uses |
@ljharb Thanks for the update! Webpack builds just fine and can read the
|
You’re missing the node resolver. Add |
That does appear to have resolved my issue, and should solve @Gautierrr's issue too when tweaking the |
Yes thanks it solves my issue but I don't understand why we have to add the |
@Gautierrr generally you only want the node resolver, unless you have webpack-specific aliases (and in that case, i'd suggest using babel to resolve them instead of webpack). You are right tho that the webpack resolver alone should theoretically be enough (although I've never omitted the node resolver in any project before) - however, it's entirely possible that webpack 5 (or enhanced-require) has broken something that used to work in webpack 4, or, that nanoid's use of the "exports" field is causing issues. We use |
Understood, thanks @ljharb! |
Ran into this with |
Hi ✋
Since the update of Webpack from v4.44.2 to v5.6.0, I get this error:
It's a very strange bug because it doesn't happen with all Node modules.
For example, here the
import/no-unresolved
rule throw an error fornanoid
but not forbowser
🤔The minimal reproducible repo: https://github.com/gautierrollin/no-unresolved-false-positive or just:
You can downgrade the Webpack version to make it work:
npm install webpack@4.44.2 webpack-cli@3.3.12 && npm run lint
My (minimal) eslint config:
Ps: my real Webpack config is bigger than the one in the reproducible repo. But it's just a minimal reproducible repo, I get the same error with
resolve.extensions
option and others...The text was updated successfully, but these errors were encountered: