My React app was working fine until today, when I run npm start the following error is displayed
Module not found: Error: Can't resolve 'util' in 'C:\Users\Lui\Desktop\React\BarPoint\node_modules\sass'
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 }
I have tried to delete the node modules and did npm i
but still error is persisted,how do i resolve this?
To solve this issue I did this following steps:-
1) delete package-lock.json file
2) delete node-modules if required
3) delete dist folder if exists.
4) npm install
Everything should work now, it was the package-lock.json that blocked npm to download old versions of dependencies.