更新时间:2021-09-17 21:43:43
npm 默认使用 cmd.exe
在 Windows 上运行脚本 - 无论您调用 npm 的 shell 是什么
可执行 来自,它解释了您的症状.[1]
npm uses cmd.exe
to run scripts on Windows by default - irrespective of what shell you happen to invoke the npm
executable from, which explains your symptom.[1]
如果您希望 npm 使用 PowerShell 来运行脚本,请使用 (npm v5.1+):
If you want npm to use PowerShell to run scripts with, use (npm v5.1+):
Windows PowerShell:
Windows PowerShell:
npm config set script-shell powershell
PowerShell 核心:
PowerShell Core:
npm config set script-shell pwsh
注意:以上配置 PowerShell 以用于所有您的项目;您也可以针对每个项目执行此操作 - 请参阅此答案.
Note: The above configures PowerShell for use with all your projects; you can also do it on a per-project basis - see this answer.
[1] ;
不是 cmd.exe
中的句号分隔符,而 '...'
-quoting 是未能识别;因此,echo
命令解释了 'test';echo 'test2'
作为要回显的文字字符串.
[1] ;
is not a stament separator in cmd.exe
, and '...'
-quoting is not recognized; therefore, the echo
command interpreted 'test'; echo 'test2'
as a literal string to echo.