If you like to use
npx to execute commands and would like to reference environment variables in your commands the solution is very simple. Adding the
--call flag to your npx command will execute the command as if it were an
npm run command, giving access to all environment variables currently set.
npx -c '< command > $npm_package_version'