Gha*_*yth 1 ant angularjs typescript angular-cli angular
当我尝试运行以下 Ant 脚本时,该脚本执行“npm”命令:
<target name ="test">
<exec executable="npm" failonerror="true">
<arg value="install" />
</exec>
</target>
Run Code Online (Sandbox Code Playgroud)
它因以下错误而失败:
Execute failed: java.io.IOException: Cannot run program "npm"
(in directory "C:\Development\workspace\traqpath\WebSource"):
CreateProcess error=2, The system cannot find the file specified
Run Code Online (Sandbox Code Playgroud)
当我尝试运行 Angular-CLI “ng”命令时,也会发生同样的情况:
<target name ="test">
<exec executable="ng" failonerror="true">
<arg value="build"/>
<arg value="--prod"/>
<arg value="--bh"/>
</exec>
</target>
Run Code Online (Sandbox Code Playgroud)
具有相同的错误消息,但对于“ng”:
Execute failed: java.io.IOException: Cannot run program "ng"
(in directory "C:\Development\workspace\traqpath\WebSource"):
CreateProcess error=2, The system cannot find the file specified
Run Code Online (Sandbox Code Playgroud)
这两个命令在Windows命令行中运行都没有问题,这意味着NodeJS安装正确,并且NodeJS路径在PATH系统变量中正确配置。
我通过修改 Ant 脚本来指定“npm”可执行文件的全名(以及第二种情况下的“ng”命令)解决了该问题:
我的新 Ant 脚本现在看起来像这样:
<target name ="test">
<exec executable="npm.cmd" failonerror="true">
<arg value="install" />
</exec>
</target>
<target name ="test">
<exec executable="ng.cmd" failonerror="true">
<arg value="build"/>
<arg value="--prod"/>
<arg value="--bh"/>
</exec>
</target>
Run Code Online (Sandbox Code Playgroud)
请注意,我使用“npm.cmd”而不是“npm”,使用“ng.cmd”而不是“ng”。
归档时间: |
|
查看次数: |
6348 次 |
最近记录: |