【发布时间】:2017-05-13 17:49:27
【问题描述】:
我使用的是 Windows 10,但我使用的是 git bash。从git bash 运行时:
DEBUG=foo node index.js
它工作正常并设置环境变量DEBUG。但如果我把它放到package.json 的scripts 部分:
"scripts": {
"start": "DEBUG=foo node index.js"
},
并从git bash 运行以下命令,我收到以下错误:
$ npm start
> nodejs@1.0.0 start C:\Users\maksym.koretskyi\Desktop\nodejs
> DEBUG=foo node index.js
'DEBUG' is not recognized as an internal or external command,
operable program or batch file.
为什么会有这种行为?
【问题讨论】:
-
您的错误是由于在
Windows环境(注意batch关键字)而不是bashshell 下执行的指令造成的。 -
谢谢,我就是这么想的。你知道为什么即使我从
git bash运行npm start还是在Windows 环境下执行DEBUG=foo node index.js吗? -
能否再次确认一下,如果
node安装正确,可能会检查Git bash中的$PATH是否有安装node的路径 -
它应该有,因为
DEBUG=foo node index.js从git bash执行得很好
标签: node.js bash package.json