Why are you doing this in the recipe of a target? Why not just put it out in the main part of your makefile?
ifndef NODE_ENV
$(error NODE_ENV is undefined)
endif
If you really want to have this done through rules, your best bet (assuming you're using a "new-enough" version of GNU make) is to use order-only prerequisites like this:
check-env:
$(if $(NODE_ENV),,$(error NODE_ENV is undefined))
sql/schema.js: sql/schema.sql | check-env
...
(note the pipe symbol |
). See the manual for details.