Closed
Description
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
A webpack build is failing with the following error:
./node_modules/xxx/node_modules/semver/classes/semver.js:30:46-69 - Error: Module not found: Error: Can't resolve 'util' in '/runner/_work/xxx/node_modules/xxx/node_modules/semver/classes'
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: { "util": require.resolve("util/") }'
- install 'util'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "util": false }
It was working in version 7.4.0
Expected Behavior
The webpack build should work without adding any node.js dependency as we want to use semver in the browser.
Steps To Reproduce
- Setup a webpack build
- add semver
- Run webpack
- See error above
I assume it was introduced due to this change:
v7.4.0...v7.5.0#diff-7917f8ef42ff71df5bde71c259d15feab8b147e3e6c2fde11b56cbf42cadea16R19
Environment
- npm: 6.14.17
- Node: 14.9.3
- OS: Ubuntu 20.04
- platform: Linux