when running node in command over a specific port, I'd start the app this way:
PORT=1234 node app.js
how do I pass the port to the forever
command? no matter what I try, it seems to not want to work.
I've tried:
forever start app.js 1234
forever start app.js PORT=1234
js application locally after closing the terminal or Application, to run the nodeJS application permanently. We use NPM modules such as forever or PM2 to ensure that a given script runs continuously. NPM is a Default Package manager for Node.
The default port for HTTP is 80 – Generally, most web browsers listen to the default port. Below is the code implementation for creating a server in node and making it listen to port 80.
What is npm forever? Forever is an npm package used to keep your script running continuously in the background. It's a handy CLI tool that helps you to manage your application in the development and production stages. To start running a script with forever, use the forever start command, followed by the script name.
PORT=1234 forever start app.js
You can try adding export PORT=1234
to app.js
Then just run with forever start app.js
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With