Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm start on new create-react-app build returns ELIFECYCLE error

Made a new react app using create-react-app and now getting the following error in the terminal when running npm start:

> react-scripts start

Attempting to bind to HOST environment variable: x86_64-apple-darwin13.4.0
If this was unintentional, check that you haven't mistakenly set it in your shell.


events.js:167
      throw er; // Unhandled 'error' event
  ^

Error: getaddrinfo ENOTFOUND x86_64-apple-darwin13.4.0
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)
Emitted 'error' event at:
    at GetAddrInfoReqWrap.doListen [as callback] (net.js:1468:12)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:17)
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:
npm ERR!     /Users/chris/.npm/_logs/2018-12-24T10_07_46_970Z-debug.log 

Tried removing the node-module folder and npm install.

like image 872
Christopher Bennett Avatar asked Dec 24 '18 10:12

Christopher Bennett


People also ask

Why is npm start giving error?

If you try to run the command from a different directory, it won't find your package. json file and the Missing script: "start" npm error is caused. If you don't have a package. json file, create one by opening your terminal in your project's root directory and running the command npm init -y .

How do I fix create react error?

i had this issue. The simple solution is to add latest versions of typescript, react-scripts libs. and then run npm install. it works for me.

Do I have to install react app again every time I start a new project?

You will have to install it separately for each project.


1 Answers

I struggled with this exact issue for an entire day. If you do unset HOST, it will solve it, but temporarily. The simple solution to this bug is as follows (this is for Mac, for Window the commands may differ):

  1. Open your bash with the following command: open ~/.bash_profile
  2. Write this down (exactly what it says) all the way down the file once the file opens: HOST="localhost"
  3. After that, save the file and quit (Command + q)
  4. Finally, reload the environment by typing this on the terminal: source ~/.bash_profile

If you do all the steps correctly, this should resolve the bug.

like image 99
Zakir Avatar answered Sep 17 '22 12:09

Zakir