Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unrecognized PORT command

In my localhost, running below command

PORT=4080 node server.js

But, it was throwing an unexpected error.

'PORT' is not recognized as an internal or external command, operable program or batch file.

Do I need to install any module or did I miss any syntax to run it properly?

like image 255
kvk30 Avatar asked Dec 14 '17 05:12

kvk30


3 Answers

Apart from cross-env, Below command can serve the purpose.

SET PORT=4080 && node server.js 

PS: Set environment variable for nodeJs, run command in project folder.

like image 154
kvk30 Avatar answered Nov 18 '22 01:11

kvk30


In Windows you can set scripts in package.json:

"start": " set PORT=portnumber && react-app-rewired start"

or

"start": " set PORT=3001 && react-script start".

It worked for me:

in package.json file

like image 20
Rishabh Avatar answered Nov 18 '22 02:11

Rishabh


  • Install this additional package cross-env in your node environment. The above command you mentioned is Unix (Ubuntu, Mac, etc…). In the windows environment, you need a different syntax and cross-env does your job.
  • You can also create an .env file with

PORT=3006

and save it in your project directory.

like image 8
go_gunner Avatar answered Nov 18 '22 02:11

go_gunner