Create-react-app: After create-react-app, `npm start` not work

Created on 17 Jul 2020  路  15Comments  路  Source: facebook/create-react-app

Describe the bug

I follow the process on (https://reactjs.org/docs/create-a-new-react-app.html) to Create React App,
npx create-react-app my-app
cd my-app
npm start
But npm start can not work and the essor message as below,

> [email protected] start /Users/cortey/Documents/GitHub/WebProject-React/my-app
> 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.
Learn more here: https://bit.ly/CRA-advanced-config

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

Error: getaddrinfo ENOTFOUND x86_64-apple-darwin13.4.0
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:26)
Emitted 'error' event at:
    at GetAddrInfoReqWrap.doListen [as callback] (net.js:1457:12)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56: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/cortey/.npm/_logs/2020-07-17T04_51_32_683Z-debug.log

The complete log of this run is here,

0 info it worked if it ends with ok
1 verbose cli [ '/Users/cortey/.nvm/versions/node/v10.16.0/bin/node',
1 verbose cli   '/Users/cortey/.nvm/versions/node/v10.16.0/bin/npm',
1 verbose cli   'start' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle [email protected]~prestart: [email protected]
6 info lifecycle [email protected]~start: [email protected]
7 verbose lifecycle [email protected]~start: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~start: PATH: /Users/cortey/.nvm/versions/node/v10.16.0/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/cortey/Documents/GitHub/WebProject-React/my-app/node_modules/.bin:/Users/cortey/.nvm/versions/node/v10.16.0/bin:/anaconda3/bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/mysql/bin:/usr/local/mysql/support-files:/Applications/Postgres.app/Contents/Versions/11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Users/cortey/.nvm/versions/node/v10.16.0/bin:/Users/cortey/opt/anaconda3/bin:/Users/cortey/opt/anaconda3/condabin:/anaconda3/bin:/Library/Frameworks/Python.framework/Versions/3.7/bin
9 verbose lifecycle [email protected]~start: CWD: /Users/cortey/Documents/GitHub/WebProject-React/my-app
10 silly lifecycle [email protected]~start: Args: [ '-c', 'react-scripts start' ]
11 silly lifecycle [email protected]~start: Returned: code: 1  signal: null
12 info lifecycle [email protected]~start: Failed to exec start script
13 verbose stack Error: [email protected] start: `react-scripts start`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/Users/cortey/.nvm/versions/node/v10.16.0/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:198:13)
13 verbose stack     at ChildProcess.<anonymous> (/Users/cortey/.nvm/versions/node/v10.16.0/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:198:13)
13 verbose stack     at maybeClose (internal/child_process.js:982:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid [email protected]
15 verbose cwd /Users/cortey/Documents/GitHub/WebProject-React/my-app
16 verbose Darwin 19.3.0
17 verbose argv "/Users/cortey/.nvm/versions/node/v10.16.0/bin/node" "/Users/cortey/.nvm/versions/node/v10.16.0/bin/npm" "start"
18 verbose node v10.16.0
19 verbose npm  v6.14.6
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] start: `react-scripts start`
22 error Exit status 1
23 error Failed at the [email protected] start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

Actually, I npx create-react-app my-app one month ago, and it works! But today, I can create a new one but cannot run it.
Plus, I changed my hosts yesterday, just add a domain, so it seems not the hosts problem.

My etc/hosts file

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1   localhost
255.255.255.255 broadcasthost
::1             localhost
127.0.0.1 api.promernstack.com ui.promernstack.com
bug report needs triage

All 15 comments

Simple solution is unset the host using this command in terminal.
unset HOST

But, this is temporary one and need to be fixed in future. Try the solution mention below to fix the bug.
Steps:

  1. Open the bash:
    open ~/.bash_profile
  1. Write this down (exactly what it says) all the way down the file once the file opens:
    HOST="localhost"

  2. Save the file and quit
    Command + q

  3. Finally, reload the environment:
    source ~/.bash_profile

Simple solution is unset the host using this command in terminal.
unset HOST

But, this is temporary one and need to be fixed in future. Try the solution mention below to fix the bug.
Steps:

  1. Open the bash:
    open ~/.bash_profile
  2. Write this down (exactly what it says) all the way down the file once the file opens:
    HOST="localhost"
  3. Save the file and quit
    Command + q
  4. Finally, reload the environment:
    source ~/.bash_profile

It works! Thanks, @aathil-Mr-ITGuy !
So do you think it is the issue related to etc/hosts files? I am still confused about the logic of this issue, could you please give me some reference to figure out why it happened?

Can you please tell how to start the first step? I am searching this file through search but can't find it.

Can you please tell how to start the first step? I am searching this file through search but can't find it.

Hi @shubhamkrswarnkar,
Do you mean the step of @aathil-Mr-ITGuy answer: open ~/.bash_profile? If yes, I think you can just type open ~/.bash_profile in your current terminal, and the .bash_profile will display.
By the way, I used the temporary solution unset HOST, because I want to figure out what caused this issue at first.

npx create-react-app my-app

by default, you should use yarn,
to use pm: npx create-react-app my-app --use-npm

@tuoying96 I am glad @aathil-Mr-ITGuy's suggestion works, I would recommend checking out Windows Environment variables on your machine and seeing if HOST is set there.

unset HOST will only persist for that shell session.

You may have some sort of virtual machine or something that has set this as a system variable for whatever reason.

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

I am also facing the same issue while executing the command "npm start". The "unset HOST" command didnt work for me.
Does someone know any other solution?

Im having the same problem with the new react app's, because I have old project and I run npm start and works fine.
Anyone have other solution? I tried the unset Host but didnt work.

This problem is only present with [email protected], downgrading to [email protected] resolved the issue.
TRY THIS

create-react-app my-app
cd my-app
npm install [email protected]
npm start

Yeah, that works.
Thanks!

@rutikwankhade But do I need to downgrade react-scripts to 2.1.8 every-time I create a new application using create-react-app?

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

issue still persisting over here 25/10/20. It seems to be persistent with Mac users, what can i do please?

Add .env file inside project folder (outside src folder) and add a line mentioned below:-
SKIP_PREFLIGHT_CHECK=true

then npm install
npm start

This problem is only present with [email protected], downgrading to [email protected] resolved the issue.
TRY THIS

create-react-app my-app
cd my-app
npm install [email protected]
npm start

No need to downgrade react-script

Add .env file inside project folder (outside src folder) and add a line mentioned below:-
SKIP_PREFLIGHT_CHECK=true

then npm install
npm start

Was this page helpful?
0 / 5 - 0 ratings

Related issues

oltsa picture oltsa  路  3Comments

barcher picture barcher  路  3Comments

adrice727 picture adrice727  路  3Comments

dualcnhq picture dualcnhq  路  3Comments

rdamian3 picture rdamian3  路  3Comments