Webpack 5: Module not found: Can't resolve 'http'
See original GitHub issueI’m importing ethersjs into my Nextjs SPA via import { ethers } from "ethers";
and I’m getting the below error:
error - ./node_modules/@ethersproject/web/lib.esm/geturl.js:11:0
Module not found: Can't resolve 'http'
Related to: https://github.com/ethers-io/ethers.js/issues/349
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:16 (7 by maintainers)
Top Results From Across the Web
Webpack 5 Errors - Cannot Resolve 'crypto', 'http', and 'https' in ...
I have created a new React project using npx create-react-app client and have encountered some issues with Webpack 5. Originally, I had errors ......
Read more >Module not found: Error: Can't resolve 'http' [Solved] | bobbyhadz
The error "Module not found: Error: Can't resolve 'http'" occurs because there has been a breaking change in Webpack version 5. To solve...
Read more >Webpack 5 errors | ImmutableX Documentation
Module not found : Error: Can't resolve 'https' in '/Users/{username}/{project-name}/node_modules/@imtbl/imx-sdk/dist' BREAKING CHANGE: webpack < 5 used to ...
Read more >Resolve | webpack
For example, when calling import 'lodash' in ES2015, the resolve options can ... Webpack 5 no longer polyfills Node.js core modules automatically which ......
Read more >[SOLVED] Im facing issues installing moralis in my app ...
Module not found : Error: Can't resolve 'http' in ... BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules...
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
I got it working by
yarn install http-browserify https-browserify
and updating next.config.js to the below:It would be great if this was documented or have a simpler method to define the needed polyfills, as I’d imagine other developers will face the same problem upgrading to webpack 5.
Wow. I didn’t know you could specify non-standard fields. :p
That field is meant more as an internal build system flag.
I have a new build system nearly done which should make everything cooperate with webpack/rollup/etc. much better without these hacks… It’s coming. 😃