In my localhost, running below command
PORT=4080 node server.js
But, it was throwing an unexpected error.
\'PORT\' is no
automatically run this port :3000,I tried windows working react
"devDependencies": {
"react-scripts": "0.8.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
Here's a moronic way I found to recreate this problem:
npm install
npm start
Receive error described in question.
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.
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:
SET PORT=8090 && nodemon server.js
that worked for me
You can try this way also
"scripts": {
"build": "concurrently \"cd client && npm build\" \"cd server && npm build\"",
"install": "(cd client && npm) && (cd server && npm)",
"start": "concurrently \"cd client && SET PORT=3000 && npm start\" \"cd server && SET PORT=3001 && npm start\"",
"start:prod": "cd server && npm start:prod"
}