cli: `sv` in windows powershell conflicts with `Set-Variable`

In powershell, sv is an alias to Set-Variable. Thus I cannot use npx sv as that conflicts with the alias which takes precedence. And the alias can for some reason not be removed, when I remove it with Remove-Item Alias:sv -Force it comes back directly afterwards.

How can I use npx sv then ?

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 19 (3 by maintainers)

Most upvoted comments

Remove-Item Alias:sv -Force -ErrorAction SilentlyContinue in the profile does fix the issue !

That does indeed work. But I ended up using pnpm in the end with pnpm dlx…

As far as I’m aware (I could be wrong), built in cmdlets like Set-Variable take precedence.

I think some versions of PowerShell look for built-in commands or aliases before checking external executables. So, since sv is already an alias for Set-Variable, PowerShell immediately interprets and runs that command instead of passing it to npx like it should.

If I’m right (can’t test), you might be able to resolve the issue by running either npx -- sv or & npx sv. If either of those work, I have a feeling this might be less a bug, more just a quirk that needs to be documented.