3

I'm trying to create a powershell alias for my ng build command which is fairly long.

node --max_old_space_size=4096 .\node_modules\@angular\cli\bin\ng build --configuration=debug --watch

Aliasing the command directly using Set-Alias -Name ngBuild -Value node --max_old_space_size=4096 .\node_modules\@angular\cli\bin\ng build --configuration=debug --watch doesn't work for me.

4
  • 1
    Set-Alias is meant for cmdlets / functions, not to store scriptblocks. I guess, an option you have is to store your command inside a function with that name you wanted. Commented May 6, 2021 at 21:57
  • You can make a function with the command, and even make an alias for that command. Commented May 6, 2021 at 21:57
  • @Santago ALWAYS seconds ahead of me haha Commented May 6, 2021 at 21:58
  • 1
    In short: Unlike in POSIX-compatible shells such as bash, you cannot include pass-through arguments in a PowerShell alias definition - you need a function for that. PowerShell aliases are simply alternative names for other commands, with no ability to "bake in" arguments. E.g., to define a short command bar that invokes command foo with fixed argument bar while passing all other arguments through, use function bar { foo bar @args } - see the linked duplicate for more information. Commented May 6, 2021 at 22:09

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.