Cross-env is a script that runs cross-platform Settings and uses environment variables (environment variables in Node).

Cross-env is the same statement and command that we want to use on both Windows and Linux.

Why cross-env

This problem is mainly caused by different operating system platforms support different Shell scripts.

For example, if you want to set environment variables in Windows using the command NODE_ENV=production, most Windows command prompts don’t have a way to do that.

Similarly, Windows and POSIX commands use environment variables differently.

For POSIX, you can use: $ENV_VAR, but on Windows you need to use %ENV_VAR% to set environment variables.

In the above case, variable references used in setting environment variables are different for different operating system platforms.

For example, we often use setting environment variables.

For different operating system environments

windows

set NODE_ENV=production

linux

export NODE_ENV=production

By the same token, wouldn’t it be a hassle if we had to make different Settings for different operating systems?

This is where our cross-env comes in.

The installation

If you encounter:

> [email protected] dev /home/vagrant/Code
> cross-env NODE_ENV=development webpack --progress --hide-modules

sh: 1: cross-env: not found
Copy the code

Cross-env is not installed on your platform.

You can run

sudo npm install --global cross-env
Copy the code

To install and configure.

www.ossez.com/t/node-cros…