0

I'm using

localhost:client davea$ npm -version
6.11.3

and following the advice here -- Issue with babel-jest dependency when running npm start in a React app , didn't do anything to help my situation. I want to start a completely blank project, so I tried

npx create-react-app client
cd client

However when I attempt to start things, I get this error

localhost:client davea$ npm start

> client@0.1.0 start /Users/davea/Documents/workspace/chicommons/maps/client
> 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": "^24.9.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/davea/Documents/workspace/node_modules/babel-jest (version: 22.4.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:

  5. 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.

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

  7. 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.

P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! client@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the client@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/davea/.npm/_logs/2020-02-11T19_49_36_594Z-debug.log

What else am I supposed to do to get this off the ground?

Dave
  • 15,639
  • 133
  • 442
  • 830
  • What happened when you followed the steps to fix it as listed in the error message you supplied? Did it change the error message you got or the exact same happened again? – Meg Feb 11 '20 at 20:00
  • You mean "Delete package-lock.json" ... and install again? Yeah same thing happens. – Dave Feb 11 '20 at 20:21
  • As the error states, fairly clearly I think, you have a babel-jest installation in your workspace/ folder, and you're trying to install inside the workspace/chicommons/maps sub-folder, and it's saying there are now conflicting versions. npm/yarn check for node_modules recursively up directories. Why are you trying to create-react-app inside a subfolder of an existing npm modules installation? Why not use a clean new folder? – Andy Ray Feb 11 '20 at 20:25
  • Yup, running "sudo rm -rf /Users/davea/Documents/workspace/node_modules" solved the problem. – Dave Feb 11 '20 at 20:29

2 Answers2

1

By default create-react-app uses Yarn. So I would suggest to use command yarn start for starting the application. And as you will be using Yarn you should have yarn.lock file. Make sure to delete package-lock.json file if exists.

Your last resort would be adding SKIP_PREFLIGHT_CHECK=true to an .env file in your project in the root directory.

AD B
  • 176
  • 2
  • 11
  • This comes from a tutorial here -- https://www.freecodecamp.org/news/create-a-react-frontend-a-node-express-backend-and-connect-them-together-c5798926047c/ . They don't say anything about "yarn start," however, I tried as you suggest and got the error, "-bash: yarn: command not found". – Dave Feb 11 '20 at 20:25
  • You should install yarn then. Go ahead and install it from [here](https://classic.yarnpkg.com/en/docs/install) – AD B Feb 11 '20 at 20:29
0

My react js project doesn't have .env file, so I have created it and put (SKIP_PREFLIGHT_CHECK=true) in it.

Jamal
  • 811
  • 5
  • 15