无法将"NODE_OPTIONS"识别为内部或外部命令 [英] 'NODE_OPTIONS' is not recognized as an internal or external command
问题描述
我在Windows 10计算机上尝试从git bash终端运行构建脚本.
I'm on a windows 10 machine trying to run a build script from the git bash terminal.
在我的终端节点上可以很好地识别,例如,当我运行node --version
时,我得到了版本.
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.
我猜我需要在PATH变量中添加一些东西才能使它起作用,但是什么呢?
I'm guessing I need to add something to my PATH variables to get this to work, but what?
推荐答案
使用 cross-env 可以轻松设置环境变量的软件包.
Use cross-env package which easily sets environment variables.
从npm安装交叉环境
Install cross-env from npm
npm i cross-env
在package.json文件中(在此示例中,您需要运行具有'NODE_OPTIONS'的'start'命令)
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>",
}
}
步骤2
在需要运行NODE_OPTIONS的脚本中添加"cross-env". (在这种情况下为开始"脚本)
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>",
}
}
这篇关于无法将"NODE_OPTIONS"识别为内部或外部命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!