19

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?

1 Answer 1

43

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!

Sign up to request clarification or add additional context in comments.

2 Comments

Did you put this in your procfile?
I'm an idiot this something you run in command line it just looks similar to procfile so i was confused.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.