2

I have an existing old react application, created with create-react-app and ejected with react-app-rewired. I'm updating the deprecated dependencies. I've already updated react-scripts to the current version (4.0.3) and everything works fine. But I need to update the style-loader lib, and this new version requires webpack 5.

The current react-scripts version is using webpack 4:

> npm ls webpack
my-app@0.1.0
└─┬ react-scripts@4.0.3
  └── webpack@4.44.2 

I found a project named webpack-5-react-script: https://www.npmjs.com/package/webpack-5-react-scripts. It seems what I need, but as my project was ejected using react-app-rewired a long time ago, I get this error when I run npm start:

Error: Cannot find module 'react-scripts/package.json'
Require stack:
- /home/.../my-app/node_modules/react-app-rewired/scripts/utils/paths.js
- /home/../my-app/node_modules/react-app-rewired/scripts/start.js

What I can do? Has anybody faced this issue?

  • It seems that I'm not the only one with this problem: https://github.com/facebook/create-react-app/issues/9664#issuecomment-917260217. Maybe the best option is to wait until react-scripts 5 comes out: https://www.npmjs.com/package/react-scripts – Adrián Paredes Sep 17 '21 at 21:14

2 Answers2

0

React app rewired start, calls react-scripts start, you would need to edit react app rewired to call webpack5-react-scripts instead.

Hcabnettek
  • 12,678
  • 38
  • 124
  • 190
0

Just download react-scripts 5.0.0 into your project?

111.eth
  • 11