To change value of process.env.PORT in Node.js, we set the PORT
variable.
For instance, we run ‘
$ PORT=1234 node app.js
from Unix or Linux to set the PORT
environment variable to 1234 before running app.js.
We can do the same thing with
$ export PORT=1234
$ node app.js
On Windows, we run
set PORT=1234
to set the port.
And on Windows PowerShell, we run
$env:PORT = 1234
to do the same thing.