---
title: Use Environment Variables with npx
description: If you use npx to execute commands and need to reference environment variables, the solution is very simple.
date: 2021-10-19
tags: npx, envrionment variables
source: https://brianchildress.co/blog/environment-variables-using-npx
---

# Use Environment Variables with npx

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:_

```sh
npx -c '< command > $npm_package_version'
```
