You often see example hello world code for Node that creates an Http Server, starts listening on a port, then followed by something along the lines of:
conso
You might be looking for process.env.PORT
. This allows you to dynamically set the listening port using what are called "environment variables". The Node.js code would look like this:
const port = process.env.PORT || 3000;
app.listen(port, () => {console.log(`Listening on port ${port}...`)});
You can even manually set the dynamic variable in the terminal using export PORT=5000
, or whatever port you want.