I'm running a Node project with Heroku as my main deploy target. In dev environment I'm using grunt to start the web server, however in production I prefer to launch the app directly with node app
Here's my Procfile:
web: bin/web
And bin/web:
#!/bin/sh
echo "NODE_ENV=" $NODE_ENV
if [ "$NODE_ENV" == "production" ]; then
echo "Starting the server with node app"
node app
else
echo "Starting the server using grunt"
grunt
fi
The first echo
is for debugging. heroku log is showing:
app[web.1]: NODE_ENV=
Basically, meaning NODE_ENV is not set. (and the app starts with grunt instead of node app
)
The docs say that "The NODE_ENV environment variable defaults to production, but you can override it if you wish"
What am I missing?
Not sure if you figured this out or not, but I had the same problem and fixed it using:
heroku config:set NODE_ENV=production
Via https://devcenter.heroku.com/articles/nodejs-support .
Good luck!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.