0

I am fairly new to ReactJS and was messing around with Material UI in a build I'm working on. I installed the package and it completely messed up my build and the ability to open the server.

When I do

npm start

I get the following error:

`> react-scripts start

There might be a problem with the project dependency tree. It is likely not a bug in Create React App, but something you need to fix locally.

The react-scripts package provided by Create React App requires a dependency:

"babel-jest": "23.6.0"

Don't try to install it manually: your package manager does it automatically. However, a different version of babel-jest was detected higher up in the tree:

/Users/peter/node_modules/babel-jest (version: 27.5.1)

Manually installing incompatible versions is known to cause hard-to-debug issues.

If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project. That will permanently disable this message but you might encounter other issues.

To fix the dependency tree, try following the steps below in the exact order:

  1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
  2. Delete node_modules in your project folder.
  3. Remove "babel-jest" from dependencies and/or devDependencies in the package.json file in your project folder.
  4. Run npm install or yarn, depending on the package manager you use.

In most cases, this should be enough to fix the problem. If this has not helped, there are a few other things you can try:

  1. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead. This may help because npm has known issues with package hoisting which may get resolved in future versions.

  2. Check if /Users/peter/node_modules/babel-jest is outside your project directory. For example, you might have accidentally installed something in your home folder.

  3. Try running npm ls babel-jest in your project folder. This will tell you which other package (apart from the expected react-scripts) installed babel-jest.

If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project. That would permanently disable this preflight check in case you want to proceed anyway.`

When I follow the directions, nothing changes. I did clean install of npm and I created the .env file that it asked.

Is my build just completely ruined?

OhItsPM
  • 11
  • 2
  • 4

2 Answers2

1

The error is because you have a node_modules folder in your home directory (/Users/peter/), (which I assume is unintended, and react-scripts thinks that your home folder contains a Node.js project). To fix the error, you should remove that directory (e.g. rm -rf /Users/peter/node_modules)

  • That fixed it! Except now I have a new issue: Error:030801C:digital envelope routines::unsupported The localhost refused to connect – OhItsPM Jan 05 '23 at 19:00
  • See https://stackoverflow.com/questions/69692842/error-message-error0308010cdigital-envelope-routinesunsupported – Live bug help - www.dialect.so Jan 05 '23 at 19:36
  • Okay thank you, changing the start to --openssl-legacy-provider helped. But now I'm facing another issue I've never seen before. It says TypeError: Cannot read properties of undefined (reading 'createElement' and shows a screen of return in App.js being red and then 17 stack frames were expanded. In the terminal, i see Compiled with warnings. and shows that my navbar.js and notfound.js are having issues – OhItsPM Jan 05 '23 at 20:50
  • I solved it, needed to import something else for react. – OhItsPM Jan 05 '23 at 20:56
0

If anyone is experiencing the same issue and removing package-lock.json and node_modules did not solve it, after a few hours I discovered that I needed to upgrade react-scripts as it wasn't the latest version.

Just update the react-scripts dependency in package.json to "react-scripts": "^5.0.1" #or whatever the latest version is...

Then delete package-lock.json and run

npm install
gal malka
  • 13
  • 1
  • 6