Upgrading create react app to version 4 gives : ReferenceError: Cannot access 'middleware' before initialization

Viewed 509

I tried upgrading react scripts to 4.0.1 and type script to "4.1.3" and react to "17.0.1". I deleted the node_modules and lock files, then installed again with yarn install command. When I run yarn start, I get error ReferenceError: Cannot access 'middleware' before initialization

enter image description here

When I set FAST_REFRESH=false in .env file app loads with no issues, So it is something with react refresh

1 Answers

It's a known issue https://github.com/facebook/create-react-app/issues/9904. It has to do with a change in Create React App. Fast Refresh, or React Refresh is about to replace Hot Reload. By default FAST_REFRESH is set to true.

For now I stick to Hot Reload, by setting FAST_REFRESH=false as you did and track the issue given above.

Related