Assuming we have the next code in the App.js,
console.log(`This is the port ${process.env.PORT}`);
Is there a way to access to the value of PORT outside the runtime process?
Assuming we have the next code in the App.js,
console.log(`This is the port ${process.env.PORT}`);
Is there a way to access to the value of PORT outside the runtime process?
Not directly, but you could use dotenv and read the env variables from a file. Then externally, you can read that file and get the PORT variable.
Values stored in process.env are environment variables, provided by your shell. In a *nix environment you can access this outside of the application like
echo $PORT
In windows you can access the environment variable like so:
echo %PORT%
It is worth noting that process.env values are not variables, and if you change the values in the runtime, it will not persist outside of the application.