Heroku NODE_ENV环境variables

我正在用Heroku运行一个Node项目作为我的主要部署目标。 在开发环境中,我使用grunt来启动Web服务器,但是在生产环境中,我更愿意直接使用node app启动应用node app

这是我的Procfile:

 web: bin/web 

和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 

第一个echo是用于debugging的。 heroku日志显示:

 app[web.1]: NODE_ENV= 

基本上,NODE_ENV没有设置。 (和应用程序开始咕噜,而不是node app

该文档说:“NODE_ENV环境variables默认为生产,但如果你愿意,你可以覆盖它”

我错过了什么?

不知道你是否知道这一点,但我有同样的问题,并使用下面的方法修复它:

 heroku config:set NODE_ENV=production 

通过https://devcenter.heroku.com/articles/nodejs-support

祝你好运!