使用参数从 Powershell 执行 Angular 服务失败 [英] Executing Angular Serve From Powershell With Parameters Fail

查看:18
本文介绍了使用参数从 Powershell 执行 Angular 服务失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在从 Powershell 脚本启动的特定端口上运行 Angular 服务器,并且 angular 报告配置失败.

 &'ng' @('服务', '--port', '5200')

<块引用>

指定的命令(serve --port 5200")无效.对于一个列表可用选项,运行ng help".

您的意思是服务"吗?

而没有端口它可以工作

&'ng' '服务'


我已经尝试过 &'ng' 'serve --port 5200'&'ng' @('serve', '--port 5200') 并得到相同的错误信息.

当尝试使用脚本中的参数执行 ng serve 时,如何解决或变通?

解决方案

将参数作为单独的标记传递给 ng(不要将列表包裹在 @(...)):

&ng 服务 '--port' 5200

I am attempting to run an angular server on a specific port launched from a Powershell script and angular reports configuration failure.

 & 'ng' @('serve', '--port', '5200')

The specified command ("serve --port 5200") is invalid. For a list of available options, run "ng help".

Did you mean "serve"?

Whereas without a port it works

& 'ng' 'serve'


I have tried & 'ng' 'serve --port 5200' and & 'ng' @('serve', '--port 5200') and it gets the same error message.

How does one resolve this or work around when attempting to execute ng serve with arguments from a script?

解决方案

Pass the arguments to ng as individual tokens (don't wrap the list in @(...)):

& ng serve '--port' 5200

这篇关于使用参数从 Powershell 执行 Angular 服务失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆