timarney / react-app-rewired

Override create-react-app webpack configs without ejecting
MIT License
9.76k stars 425 forks source link

Cannot read property 'push' of undefined #615

Closed Grain-full closed 2 years ago

Grain-full commented 2 years ago

I update react-scripts to v5.0.0, and then I use react-app-rewired to start my project, but show me Cannot read property 'push' of undefined. why ?

Grain-full commented 2 years ago

react-app-rewired is 2.2.1

dawnmist commented 2 years ago

What is the content of your config-overrides.js file? What packages are you using?

Without more details, I can't help. React-app-rewired is known to work with react-scripts 5.0, so the issue will be related to your environment or packages or overrides somewhere.

Jobsonvarghese commented 2 years ago

Same I'm also getting Cannot read property 'push' of undefined. after running the start

Jobsonvarghese commented 2 years ago

image

dawnmist commented 2 years ago

The most likely cause is that something is trying to add something to an array, but the array doesn't exist.

As already stated, I need details on what you're doing in order to duplicate the issue.

The error message is a generic one that could be coming from any of the tools in the build system, or from your own config-overrides. I'm not trying to be difficult - I simply cannot do anything to help without detailed information on what your environment is.

Grain-full commented 2 years ago

Thank you for your tips. Maybe I should review my code. I have a question that react-app-rewired have use immer with the react-dev-utils ?

dawnmist commented 2 years ago

Does create-react-app/react-scripts use immer by default? It is not a dependency added by react-app-rewired, but if it is used by react-scripts it will be brought in by react-scripts.

React-app-rewired works by wrapping around create-react-app's normal react-scripts build and injecting your modified configuration into the build just before react-scripts would normally use it. This allows more customisation of the build than create-react-app would normally provide, but it doesn't start pulling in additional dependencies unless you explicitly add them to the build. Basically, if create-react-app uses a library by default it will be present. If it is not something that create-react-app uses by default, you would need to manually add it yourself if you want to use it.