简体   繁体   English

无法将“ NODE_ENV”识别为内部或外部命令

[英]'NODE_ENV' is not recognized as an internal or external command

I have an app which is working perfectly on linux but when I execute it on windows I get this error. 我有一个可以在Linux上完美运行的应用程序,但是当我在Windows上执行该应用程序时,出现此错误。

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

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

npm
 ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! aaa@1.0.0 webpack-watch: `NODE_ENV='debug' webpack --progress -d -colors --watch`
npm ERR! Exit status 1
npm ERR!

I have tried this in cmd. 我已经在cmd中尝试过了。

SET NODE_ENV=debug

which I found here “NODE_ENV” is not recognized as an internal or external command 我在这里找到的“ NODE_ENV”未被识别为内部或外部命令

And here is snippet of code package.json where I guess is my mistake. 这是代码package.json的代码段,我想这是我的错误。

"webpack-watch": "NODE_ENV='debug' webpack --progress -d --colors --watch",
"server-watch": "NODE_ENV='debug' nodemon backend/server.js"

Windows doesn't understand the syntax var=value cmd1 arg1 . Windows无法理解语法var=value cmd1 arg1 You need to adapt the NPM run tasks to use Windows' syntax: 您需要调整NPM运行任务以使用Windows的语法:

"webpack-watch-win": "set NODE_ENV=debug & webpack ..."
"server-watch-win": "set NODE_ENV=debug & nodemon ..."

....but there are probably more errors you will hit downstream. ....但是您可能会在下游遇到更多错误。 This should at least get you past the environment variable declaration, though. 但是,这至少应该使您摆脱了环境变量声明。 Node is strongly rooted in *nix shells, not cmd.exe. 节点牢固地植根于* nix外壳,而不是cmd.exe。

Setup your NODE_ENV with export. 通过导出设置您的NODE_ENV。 So in your package.json add in your scripts block 所以在你的package.json中添加你的脚本块

    "scripts":{
        "webpack-watch": "export NODE_ENV='debug' && webpack --progress -d --colors --watch",
        "server-watch": "export NODE_ENV='debug' && nodemon backend/server.js"
    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 JSDocs (better docs) 'NODE_ENV' 不被识别为内部或外部命令、可运行程序或批处理文件 - JSDocs (better docs) 'NODE_ENV' is not recognized as an internal or external command, operable program or batch file NODE_ENV' 不是内部或外部命令,也不是可运行的程序或批处理文件 - NODE_ENV' is not recognized as an internal or external command, operable program or batch file node_modules 未被识别为内部或外部命令 - node_modules is not recognized as an internal or external command babel-node --presets 节点 '.' 不被识别为内部或外部命令, - babel-node --presets node '.' is not recognized as an internal or external command, babel-node 未被识别为内部或外部命令 - Babel 7 - babel-node is not recognized as internal or external command - Babel 7 [NODEMON]- babel-node 未被识别为内部或外部命令 - [NODEMON]- babel-node not recognized as internal or external command “节点”不是内部命令或外部命令、可执行程序或批处理文件 - 'node' is not recognized as an internal command or external, an executable program or a batch file 无法将“节点”识别为内部或外部命令,可操作程序或批处理文件 - 'node' is not recognized as an internal or external command, operable program or batch file Cat不被视为内部或外部命令 - Cat is not recognized as an internal or external command 无法将“ nodeunit”识别为内部或外部命令, - 'nodeunit' is not recognized as an internal or external command,
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM