Categories
JavaScript Answers

How to change value of process.env.PORT in Node.js?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *