loader]), you can do as follows: ```json { "scripts": { "test": "cross-env TS_NODE_COMPILER_OPTIONS={\\\"module\\\":\\\"commonjs\\\"} node some_file.test.ts" } } ``` Pay special attention to the **triple backslash** `(\\\)` **before** the **double quotes** `(")` and the **absence** of **single quotes** `(')`. Both of these conditions have to be met in order to work both on Windows and UNIX. ## `cross-env` vs `cross-env-shell` The `cross-env` module exposes two bins: `cross-env` and `cross-env-shell`. The first one executes commands using [`cross-spawn`][cross-spawn], while the second one uses the `shell` option from Node's `spawn`. The main use case for `cross-env-shell` is when you need an environment variable to be set across an entire inline shell script, rather than just one command. For example, if you want to have the environment variable apply to several commands in series then you will need to wrap those in quotes and use `cross-env-shell` instead of `cross-env`. ```json { "scripts": { "greet": "cross-env-shell GREETING=Hi NAME=Joe \"echo $GREETING && echo $NAME\"" } } ``` The rule of thumb is: if you want to pass to `cross-env` a command that contains special shell characters _that you want interpreted_, then use `cross-env-shell`. Otherwise stick to `cross-env`. On Windows you need to use `cross-env-shell`, if you want to handle [signal events](https://nodejs.org/api/process.html#process_signal_events) inside of your program. A common case for that is when you want to capture a `SIGINT` event invoked by pressing `Ctrl + C` on the command-line interface. ## Windows Issues Please note that `npm` uses `cmd` by default and that doesn't support command substitution, so if you want to leverage that, then you need to update your `.npmrc` to set the `script-shell` to powershell. [Learn more here](https://github.com/kentcdodds/cross-env/issues/192#issuecomment-513341729). ## Inspiration I originally created this to solve a problem I was having with my npm scripts in [angular-formly][angular-formly]. This made contributing to the project much easier for Windows users. ## Other Solutions - [`env-cmd`](https://github.com/toddbluhm/env-cmd) - Reads environment variables from a file instead - [`@naholyr/cross-env`](https://www.npmjs.com/package/@naholyr/cross-env) - `cross-env` with support for setting default values ## Issues _Looking to contribute? Look for the [Good First Issue][good-first-issue] label._ ### πŸ› Bugs Please file an issue for bugs, missing documentation, or unexpected behavior. [**See Bugs**][bugs] ### πŸ’‘ Feature Requests This project is in maintenance mode and no new feature requests will be considered. [**Learn more**](https://github.com/kentcdodds/cross-env/issues/257) ## Contributors ✨ Thanks goes to these people ([emoji key][emojis]):

Kent C. Dodds

πŸ’» πŸ“– πŸš‡ ⚠️

Ya Zhuang

πŸ”Œ πŸ“–

James Harris

πŸ“–

compumike08

πŸ› πŸ“– ⚠️

Daniel RodrΓ­guez Rivero

πŸ› πŸ’» πŸ“–

Jonas Keinholz

πŸ› πŸ’» ⚠️

Hugo Wood

πŸ› πŸ’» ⚠️

Thiebaud Thomas

πŸ› πŸ’» ⚠️

Daniel Rey LΓ³pez

πŸ’» ⚠️

Amila Welihinda

πŸš‡

Paul Betts

πŸ› πŸ’»

Turner Hayes

πŸ› πŸ’» ⚠️

Suhas Karanth

πŸ’» ⚠️

Sven

πŸ’» πŸ“– πŸ’‘ ⚠️

D. NicolΓ‘s Lopez Zelaya

πŸ’»

Johan Hernandez

πŸ’»

Jordan Nielson

πŸ› πŸ’» ⚠️

Jason Cooke

πŸ“–

bibo5088

πŸ’»

Eric Berry

πŸ”

MichaΓ«l De Boey

πŸ’»

Lauri Eskola

πŸ“–

devuxer

πŸ“–

Daniel

πŸ“–
This project follows the [all-contributors][all-contributors] specification. Contributions of any kind welcome! > Note: this was added late into the project. If you've contributed to this > project in any way, please make a pull request to add yourself to the list by > following the instructions in the `CONTRIBUTING.md` ## LICENSE MIT [npm]: https://npmjs.com [node]: https://nodejs.org [build-badge]: https://img.shields.io/github/workflow/status/kentcdodds/cross-env/validate?logo=github&style=flat-square [build]: https://github.com/kentcdodds/cross-env/actions?query=workflow%3Avalidate [coverage-badge]: https://img.shields.io/codecov/c/github/kentcdodds/cross-env.svg?style=flat-square [coverage]: https://codecov.io/github/kentcdodds/cross-env [version-badge]: https://img.shields.io/npm/v/gatsby-remark-embedder.svg?style=flat-square [package]: https://www.npmjs.com/package/gatsby-remark-embedder [downloads-badge]: https://img.shields.io/npm/dm/gatsby-remark-embedder.svg?style=flat-square [npmtrends]: http://www.npmtrends.com/gatsby-remark-embedder [license-badge]: https://img.shields.io/npm/l/gatsby-remark-embedder.svg?style=flat-square [license]: https://github.com/kentcdodds/cross-env/blob/master/LICENSE [prs-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square [prs]: http://makeapullrequest.com [coc-badge]: https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square [coc]: https://github.com/kentcdodds/cross-env/blob/master/other/CODE_OF_CONDUCT.md [emojis]: https://allcontributors.org/docs/en/emoji-key [all-contributors]: https://github.com/all-contributors/all-contributors [all-contributors-badge]: https://img.shields.io/github/all-contributors/kentcdodds/cross-env?color=orange&style=flat-square [bugs]: https://github.com/kentcdodds/cross-env/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+label%3A%22%F0%9F%90%9B+Bug%22+sort%3Acreated-desc [good-first-issue]: https://github.com/kentcdodds/cross-env/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc+label%3A%22good+first+issue%22 [angular-formly]: https://github.com/formly-js/angular-formly [cross-spawn]: https://www.npmjs.com/package/cross-spawn [malware]: http://blog.npmjs.org/post/163723642530/crossenv-malware-on-the-npm-registry [ts-loader]: https://www.npmjs.com/package/ts-loader [win-bash]: https://msdn.microsoft.com/en-us/commandline/wsl/about