Not sure if there's a better way. It doesn't seem we can do this via an environment variable.
Fixes #29507 (closed)
BTW another approach I experimented with was using $npm_package_engines_node
. This works as long as the node version isn't a range, i.e. if it is 10
it works fine.