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

本秂侑毒 提交于 2019-12-21 20:35:52

问题


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! aqi@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the aqi@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/chris/.npm/_logs/2018-12-24T10_07_46_970Z-debug.log 

Tried removing the node-module folder and npm install.


回答1:


type unset HOST in the terminal. It will solve the issue.




回答2:


I was able to fix the similar error by running npm install create-react-app instead of npm install -g create-react-app. Hope it helps.




回答3:


you should create .env files

https://facebook.github.io/create-react-app/docs/adding-custom-environment-variables#adding-development-environment-variables-in-env

read this Environments in Create React App

https://serverless-stack.com/chapters/environments-in-create-react-app.html




回答4:


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.



来源:https://stackoverflow.com/questions/53912056/npm-start-on-new-create-react-app-build-returns-elifecycle-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!