Can't resolve 'crypto' - updating webpack to v.5
See original GitHub issueHello,
To people like me that updated a project to webpack 5 and dropbox 9 and got this error:
ERROR in ./node_modules/dropbox/dist/Dropbox-sdk.min.js 1:30619-30636
Module not found: Error: Can't resolve 'crypto' in '/.../node_modules/dropbox/dist'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "crypto": require.resolve("crypto-browserify") }'
- install 'crypto-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "crypto": false }
The solution I’ve found was:
install node-polyfill-webpack-plugin
and on webpack config:
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin")
module.exports = {
// Other rules...
plugins: [
new NodePolyfillPlugin()
]
}
Hope this will help, I’ve lost a lot of time to figuring out it…
Issue Analytics
- State:
- Created 2 years ago
- Reactions:9
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Webpack 5 Errors - Cannot Resolve 'crypto', 'http', and 'https' in ...
Instead of using Webpack 5, an alternative solution I have found is to downgrade to webpack@4.46.0 and react-scripts@4.0.3 .
Read more >Module not found: Error: Can't resolve 'crypto' [Solved]
The error "Module not found: Error: Can't resolve 'crypto'" occurs because there has been a breaking change in Webpack version 5. To solve...
Read more >To v5 from v4 - webpack
Upgrade webpack 4 and its plugins/loaders · Make sure your build has no errors or warnings · Make sure to use mode ·...
Read more >Can't resolve 'crypto' - updating webpack to v.5 - Bountysource
Can't resolve 'crypto' - updating webpack to v.5. ... To people like me that updated a project to webpack 5 and dropbox 9...
Read more >angular breaking change: webpack < 5 used to include ...
webpack 5 angular polyfill for node.js crypto-js ... If you are in vue and your error starts like this 'Module not found: Error:...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you! So helpful. My site was a Laravel Vue site so it was slightly different. I installed the node-polyfill-webpack-plugin like you suggested.
npm install node-polyfill-webpack-plugin
And, I had to add the following code to webpack.mix.js
Thank you sooooo much! I spent whole afternoon to fix it:) Two tips: 1.If you build your project using
creat-react-app
, thewebpack.config.js
is innode_modules/react-scripts/config
2.Be careful,new NodePolyfillPlugin()
should be set inplugins
notresolve.plugins
. I made this mistake at first time.