首页 > 解决方案 > 如何从 VS Code 终端执行两个命令?

问题描述

我必须从 VS Code 终端执行以下命令。我在 Windows 10 机器上运行我的应用程序。

set DEBUG=app & node app.js

当我运行上述命令时,终端会给我以下错误消息。

    At line:1 char:15
   + set DEBUG=app & node app.js
   +               ~
   The ampersand (&) character is not allowed. The & operator is reserved for 
   future use; wrap an ampersand in double quotation marks
   ("&") to pass it as part of a string.
    + CategoryInfo          : ParserError: (:) [], 
      ParentContainsErrorRecordException
    + FullyQualifiedErrorId : AmpersandNotAllowed

但是,当我从命令窗口分别运行相同的命令时,它会按预期执行。

标签: node.jsvisual-studio-code

解决方案


换成这样&;

set DEBUG=app;node app.js

VSCode用作Powershell其终端,并且在Powershell命令分隔符中;不是&

在此处查看 MSDN 博客

希望这可以帮助!


推荐阅读