I am not very experienced in Nodejs but I am trying to fetch some some information in my node app that I will pass from CMD/terminal that I will access through process.env in my app.
For example, I want to pass PORT NUMBER through env in my node and fetching the same using below line:
const PORT = process.env.PORT || 3001
and I am passing port number at the time of running node app using below command line:
node server.js PORT=4200
The above one is not working. After searching on google, many people giving solution to achieve the same by running below command line:
PORT=4200 node server.js
By running above command, I am getting error in command line as given below:
'PORT' is not recognized as an internal or external command, operable program or batch file.
Can someone please let me know, how can I pass variable at the time of running node app and access the same in node app. I don't want to use any env file. I just only want to pass info from command line.
Thanks in advance