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

我的梦境 提交于 2020-12-02 07:07:54

问题


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?


回答1:


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>",
    }
}


来源:https://stackoverflow.com/questions/53948521/node-options-is-not-recognized-as-an-internal-or-external-command

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!