0

I started a react project, but I am getting around 50 errors, each one telling me to do the same thing, but with a different library.

Example:

Module not found: Error: Can't resolve 'buffer' in 'C:\Users\myname\myproject\main\my-project-name\src\node_modules\buffer-equal-constant-time'

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: { "buffer": require.resolve("buffer/") }'
    - install 'buffer'
If you don't want to include a polyfill, you can use an empty module like this:
    resolve.fallback: { "buffer": false }

I got these for many other libraries such as https, query string, and more.

I have already tried methods like instead of doing "start": "react-scripts start", using "start": "react-app-rewired start", but it just gives me more errors saying that it doesn't exist. I have been having this problem for a week now, thanks in advance!

bonk
  • 33
  • 3
  • Did you create the project using create-react-app? – Humanoid Mk.12 Jul 07 '23 at 01:52
  • I think you read the https://stackoverflow.com/questions/64557638/how-to-polyfill-node-core-modules-in-webpack-5 – Humanoid Mk.12 Jul 07 '23 at 01:55
  • That answer means you have to override webpack configuration using react-app-rewired library. For fixing your issues, you are going to set polyfills at webpack.config.js file. But if you created project using CRA, then the CRA project hides webpack.config.js file before you eject the project. By using react-app-rewired you can override it. – Humanoid Mk.12 Jul 07 '23 at 01:59
  • @HumanoidMk.12 I used create-react-app. – bonk Jul 07 '23 at 02:18
  • @HumanoidMk.12 I tried to use the react-app-rewired but it said it didn't exist. – bonk Jul 07 '23 at 02:18
  • Did you install the react-app-rewired library using npm install react-app-reqwired or yarn install react-app-rewired? – Humanoid Mk.12 Jul 07 '23 at 02:19
  • After putting in the config-override.js file and doing the react-app-rewired stuff, I'm still getting errors. Do I have to npm install every single library? – bonk Jul 07 '23 at 02:23
  • Did you followed Vitto's solution? at https://stackoverflow.com/questions/64557638/how-to-polyfill-node-core-modules-in-webpack-5 . You have to set fallbacks refered in the errors and install it – Humanoid Mk.12 Jul 07 '23 at 02:35

0 Answers0