Skip to content

Commit aef2698

Browse files
committed
Merge pull request heroku#252 from heroku/node-env-prod
default to NODE_ENV=production for build and runtime
2 parents aeac9d6 + 459ebb6 commit aef2698

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
- Fix runtime signature cache invalidation
44
- Provide error messaging for un-downloadable binaries
5+
- Default to NODE_ENV=production for both build and runtime
56

67
## v77
78

lib/environment.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,19 @@ create_default_env() {
22
export NPM_CONFIG_PRODUCTION=${NPM_CONFIG_PRODUCTION:-true}
33
export NPM_CONFIG_LOGLEVEL=${NPM_CONFIG_LOGLEVEL:-error}
44
export NODE_MODULES_CACHE=${NODE_MODULES_CACHE:-true}
5+
export NODE_ENV=${NODE_ENV:-production}
56
}
67

78
list_node_config() {
89
echo ""
910
printenv | grep ^NPM_CONFIG_ || true
1011
printenv | grep ^NODE_ || true
12+
13+
if [ "$NPM_CONFIG_PRODUCTION" = "true" ] && [ "$NODE_ENV" != "production" ]; then
14+
echo ""
15+
echo "npm scripts will see NODE_ENV=production (not '${NODE_ENV}')"
16+
echo "https://docs.npmjs.com/misc/config#production"
17+
fi
1118
}
1219

1320
export_env_dir() {

profile/nodejs.sh

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ calculate_concurrency() {
1010
WEB_CONCURRENCY=$WEB_CONCURRENCY
1111
}
1212

13-
log_concurrency() {
14-
echo "Detected $MEMORY_AVAILABLE MB available memory, $WEB_MEMORY MB limit per process (WEB_MEMORY)"
15-
echo "Recommending WEB_CONCURRENCY=$WEB_CONCURRENCY"
16-
}
17-
1813
detect_memory() {
1914
local default=$1
2015
local limit=$(ulimit -u)
@@ -29,9 +24,9 @@ detect_memory() {
2924

3025
export PATH="$HOME/.heroku/node/bin:$HOME/bin:$HOME/node_modules/.bin:$PATH"
3126
export NODE_HOME="$HOME/.heroku/node"
27+
export NODE_ENV=${NODE_ENV:-production}
3228

3329
calculate_concurrency
34-
log_concurrency
3530

3631
export MEMORY_AVAILABLE=$MEMORY_AVAILABLE
3732
export WEB_MEMORY=$WEB_MEMORY

0 commit comments

Comments
 (0)