'Update webpack 4 to webpack 5 on an existing create-react-app ejected with react-app-rewired
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
[email protected]
└─┬ [email protected]
└── [email protected]
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?
Solution 1:[1]
React app rewired start, calls react-scripts start, you would need to edit react app rewired to call webpack5-react-scripts instead.
Solution 2:[2]
Just download react-scripts 5.0.0 into your project?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Hcabnettek |
Solution 2 | 111.eth |