Reputation: 31
I'm trying to use an NPM package called "libsodium-wrappers" inside a browser with React using Create React App, but getting the following error:
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: { "path": require.resolve("path-browserify") }'
- install 'path-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "path": false }
After searching the web about this, I found that I may downgrade the "react-scripts" to version 4, but I really don't want to do this, as I will need to reinstall everything and this may break things.
Are there any working solutions to this besides the above one?
Thanks
Upvotes: 3
Views: 965
Reputation: 19
Do yarn add util
(alternatively, npm install util
). It worked for me.
Upvotes: 0
Reputation: 956
It may be related to a component library you may be using. I came across you question while attempting to address this very same issue. I'm using react-bootstrap-table2 in a project that is causing this issue for me. I believe I may have resolved it by installing the events package (specifically for react-bootstrap-table2's needs. In this case maybe try this:
yarn add path -D
Hopefully in this case that may "bump" the needle in a positive direction for you.
Upvotes: 1