1

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?

1
  • 1
    Don't group the arguments together like that: & ng serve '--port' 5200 should work Commented Jun 14, 2021 at 15:47

1 Answer 1

1

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

& ng serve '--port' 5200
Sign up to request clarification or add additional context in comments.

1 Comment

That's definitely the best way to do it (as an aside: the quoting around --port is optional), but it's worth noting that the first command in the question works too: -- & 'ng' @('serve', '--port', '5200') (or just & 'ng' ('serve', '--port', '5200')) - given that an array's elements are passed as individual arguments to external programs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.