Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm start error with create-react-app with an Error Called -ELIFECYCLE

Tags:

reactjs

I am learning a ReactJs course and while creating FirstReactApp using commands in window-7.

npm install -g create-react-app 
npm create-react-app

Both of this code works fine but when i am trying to start the server using npm start then i am getting an error called

ELiFECYLE

Below are the errors i am getting.

C:\my-react-app>npm start

> [email protected] start C:\my-react-app
> react-scripts start

Starting the development server...

events.js:174
      throw er; // Unhandled 'error' event
      ^enter code here

Error: spawn cmd ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
    at onErrorNT (internal/child_process.js:415:16)
    at process._tickCallback (internal/process/next_tick.js:63:19)
Emitted 'error' event at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:246:12)
    at onErrorNT (internal/child_process.js:415:16)
    at process._tickCallback (internal/process/next_tick.js:63:19)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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:
like image 743
Asif Ahmad Avatar asked Apr 25 '19 17:04

Asif Ahmad


1 Answers

I faced the same issue and after banging my head for a while I figured out the problem. It is a very easy fix.

You just need to change the version of your react-scripts to 2.1.8 in your project's package.json file.

If you don't understand then Follow these baby steps :P .

1 Open the file package.json

This file is just inside your project folder. If you are using an editor like VSCode then you can use it to see this file.

2 Change react-scripts version

Inside package.json you will see dependencies block.

  "dependencies": {
    "react": "^16.8.6",
    "react-dom": "^16.8.6",
    "react-scripts": "3.0.0"
  },

Right now we have the latest version which is 3.0.0. And I guess this is the real culprit here.

Change it to 2.1.8. See the image snap of my project.

enter image description here

3 Run npm install again and try npm start

Now it will work. I don't know why the version 3.0.0 is causing issue. But at this moment I think there is some bug, or may be anything else that I don't know yet.

May be the issue is something else, and something more specific. But so far I figured out this only.

Hope this helps you. Thank You :)

like image 125
Belal Khan Avatar answered Oct 10 '22 13:10

Belal Khan