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 -c
/ --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.
Example:
1 | npx -c '< command > $npm_package_version' |