Package Exports
- cross-env
- cross-env/bin/cross-env.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cross-env) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
cross-env
This micro-lib allows you to provide a script which sets an environment using unix style and have it work on windows too
Usage
I use this in my npm scripts:
{
"scripts": {
"build": "cross-env NODE_ENV=production webpack --config build/webpack.config.js"
}
}Ultimately, the command that is executed (using spawn) is:
webpack --config build/webpack.config.jsThe NODE_ENV environment variable will be set by cross-env
Why?
Windows will choke when you set environment variables with NODE_ENV=production like that. This makes it so you can
have a single command without worrying about setting the environment variable properly for the platform. Just set it
like you would if it's running on a unix system, and cross-env will take care of setting it properly.
Known limitations
If you plan to do something like this:
cross-env FOO=bar && echo $FOOAnd expect it to output bar you're going to be sad, for two reasons:
- Technically, those will run as two separate commands, so even though
FOOwill properly be set tobarin the first command, theecho $FOOwill not. - When
echo $FOOruns, the$FOOvariable is replaced with the variable value, before it's even passed tocross-env(though, as indicated in #1, that doesn't happen anyway)
The main use case for this package is to simply run another script which will (itself) respond to the environment variable. These limitations are not a problem in that scenario (like in the example).
LICENSE
MIT