【发布时间】:2017-06-25 01:24:00
【问题描述】:
我想使用 Powershell 运行 ExpressJS 应用程序。当我使用SET DEBUG=myApp:* & npm start 时,它与 cmd 一起工作,但它在 powershell 中不起作用。错误信息如下:
At line:1 char:24
+ SET DEBUG=helloworld:* & npm start
+ ~
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
我曾尝试消除 & 符号或将其包含在引号中,但无济于事;我不断收到更多错误消息。我用谷歌搜索了这个,但没有找到答案。
我想知道在 powershell 中使用什么命令来运行我的 ExpressJS 应用程序。
通过使用其他用户建议的一些其他命令,我收到以下错误:
PS C:\Users\User\myNode\helloworld> [Environment]::SetEnvironmentVariable("DEBUG","helloworld:"); &npm 开始 在行:1 字符:61 + [环境]::SetEnvironmentVariable("DEBUG","helloworld:"); &np ... + ~ 方法调用中缺少 ')'。 在行:1 字符:61 + ... Environment]::SetEnvironmentVariable("DEBUG","helloworld:"); &npm ... + ~~ 表达式或语句中出现意外的标记“”。 在行:1 字符:63 + ... nvironment]::SetEnvironmentVariable("DEBUG","helloworld:"); &npm ... + ~ 表达式或语句中出现意外的标记 ')'。 + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : MissingEndParenthesisInMethodCall
PS C:\Users\User\myNode\helloworld> [Environment]::SetEnvironmentVariable("DEBUG","helloworld:* & npm start") PS C:\Users\User\myNode\helloworld>
【问题讨论】:
-
$env:DEBUG='helloword:*'; npm start -
谢谢,但我仍然收到该命令的错误
-
你能展示更多你的代码以及你在哪里使用
Debug吗?没有看到更多,我们正在猜测您要做什么。其中之一可能是您正在寻找的:[Environment]::SetEnvironmentVariable("DEBUG","helloworld:*"); & npm start或[Environment]::SetEnvironmentVariable("DEBUG","helloworld:* & npm start") -
我已经编辑了我的问题,包括我使用得到的错误:
-
[环境]::SetEnvironmentVariable("DEBUG","helloworld:*"); & npm 开始
标签: node.js powershell express