Covid19india-react: How to make this app work both in Linux and Windows? [Help Needed]

Created on 26 Mar 2020  路  11Comments  路  Source: covid19india/covid19india-react

Hi Devs,

I am new to react. Need advice.

I am a windows user. I couldn't run the website initially. I got 'PORT' is not recognized error.

To fix it I did these:

  • Installed dotenv package and created a .env file with PORT=3000.
  • Installed cross-env
  • Removed PORT=3000 from here "react-scripts start css-watch"

It started working. Can you please advise is it correct or not? And how do we make this work both in Linux as well as Windows?

Thanks
Mani

Most helpful comment

I was also facing the same problem this is how i resolved it. On windows you can simply start by

  1. cloning the project files then use npm install -D to install all the required dependencies
  2. after this you can do npm run build to build the project.
  3. run npm install -g serve to serve the project on browser
  4. at last run serve -s build and this will generate localhost address.
    windows

All 11 comments

I was also facing the same problem this is how i resolved it. On windows you can simply start by

  1. cloning the project files then use npm install -D to install all the required dependencies
  2. after this you can do npm run build to build the project.
  3. run npm install -g serve to serve the project on browser
  4. at last run serve -s build and this will generate localhost address.
    windows

I tried the same in ubuntu 18.04 LTS
The server is running but the browser responds
404 the requested path cannot be found

Any solution to this?

Thanks, @SanjeevYadavcr7. I am able to run it through this approach but it lost the instant updates (hot reload) feature. Whenever I make any changes I need to rebuild again which takes some time.

I tried the same in ubuntu 18.04 LTS
The server is running but the browser responds
404 the requested path cannot be found

Any solution to this?

In Linux you can just do this

npm i && npm start

This error comes up
image

Added the installation method for windows in readme.
PR: https://github.com/covid19india/covid19india-react/pull/177

This error comes up
image

Did you run npm install ?

yes

This worked for me.

In package.json under scripts -> start replace existing command to following

SET PORT=3001 && react-scripts start css-watch

But I guess this may not work in Linux.

The best solution for this is that we can create an .env file in the root of our application and set the PORT environment variable as 3001 there. That way we can run this app in both Linux and windows system. I can share a PR if required.

Closed since future revision of codebase wouldn't require setting the port.

Was this page helpful?
0 / 5 - 0 ratings