Reputation: 141
I am needing to check if my node js app using ExpressJS is running on my localhost (Development env.) and not on the live server and execute certain code if so. This has to be done server side. Any ideas how to check this?
Upvotes: 3
Views: 3129
Reputation: 3731
Pass process.env variable to your node.js instance like this (for example)
node -e 'process.env.NODE_ENV = "development"'
and then just use
if(process.env.NODE_ENV === 'development') {
...
}
Upvotes: 7