Question

'NODE_OPTIONS' is not recognized as an internal or external command

I'm on a windows 10 machine trying to run a build script from the git bash terminal.

On my terminal node is recognized just fine, for example I get the version when I run node --version.

But running the build script fails with the following error:

'NODE_OPTIONS' is not recognized as an internal or external command,
operable program or batch file.

I'm guessing I need to add something to my PATH variables to get this to work, but what?

 48  50660  48
1 Jan 1970

Solution

 61

Use cross-env package which easily sets environment variables.

Step 1:

Install cross-env from npm

npm i cross-env

In your package.json file (In this example your need is to run 'start' command which has 'NODE_OPTIONS')

{
    "name": "your-app",
    "version": "0.0.0",
    "scripts": {
    ...
    "start": "NODE_OPTIONS=<your options> <commands>",
    }
}

Step 2

Add 'cross-env' in the script which you need to run NODE_OPTIONS. (In this case 'start' script)

{
    "name": "your-app",
    "version": "0.0.0",
    "scripts": {
    ...
    "start": "cross-env NODE_OPTIONS=<your options> <commands>",
    }
}
2019-05-14

Solution

 47

For me installing the below mentioned package solved the problem

npm install -g win-node-env
2021-07-18