This is my Makefile:
start:
make start-prod
start-dev:
@NODE_ENV=development
make start-bare
start-prod:
@NODE_ENV=production
make start-bare
start-bare:
node src/bootstrap
test:
@NODE_ENV=test
mocha --ignore-leaks $(shell find ./test -name \*test.js)
.PHONY: start start-dev start-prod start-bare test
When I run make start-dev
then process.env.NODE_ENV
equals undefined
. Why is this so?
Inside a makefile target, each line is a separate shell instance, so setting an environment variable in one won't transfer over to the other. Instead do something like:
start-prod:
@NODE_ENV=production \
make start-bare
or
start-prod:
@NODE_ENV=production make start-bare
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With