Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create-react-app error

I would like to use create-react-app, so I follow the instruction:

npm install -g create-react-app
create-react-app my-app
cd my-app/
npm start

But I have error on last step. After running npm start I get error:

Could not find an open port at linux-llw5. Network error message: getaddrinfo ENOTFOUND linux-llw5

How can I fix it?

like image 930
qwe asd Avatar asked Jun 29 '17 13:06

qwe asd


People also ask

Why react app is not creating?

If you really need create-react-app , you might need to reinstall Node and reconfigure your dependencies to ensure you have a fresh start with Node, npm, npx, and the like.

Why npm install create react app not working?

We no longer support global installation of Create React App. The current solution is simple — run create-react-app and target the latest version. Different versions of npm may help as well, and you can upgrade using the following command. Please note that this may affect other projects on your system.

Can't resolve Web Vitals create react app?

To solve the error "Module not found: Error: Can't resolve 'web-vitals'", make sure to install the web-vitals package by opening your terminal in your project's root directory and running the command npm install --save-dev web-vitals and restart your development server.


2 Answers

Your machine probably has a global HOST environment variable so Create React App tries to find an open port on it instead of the default localhost. Delete the environment variable and it should work fine as you want.

Alternatively you can explicitly change start in scripts in package.json to run HOST=localhost react-scripts start. But this seems a bit complex.

like image 56
Dan Abramov Avatar answered Sep 28 '22 14:09

Dan Abramov


If you set variable in command line and run

...
cd my-app/
HOST=localhost npm start

application should start correctly

like image 34
Vladislav Kysliy Avatar answered Sep 28 '22 16:09

Vladislav Kysliy