powershellvisual-studio-codeterminal

ng server command opens file "open option menu"


When I use 'ng' in the Visual Studio terminal or PowerShell, the following window opens. I don't know how to solve it.

I cannot create components, schematics.

Every time 'ng' is called, the following window pops up:

What appears when I start NG

@mklement0 I tried reinstalling: Node.js PowerShell-7.2.3-win-x64

Problem solved, using :

Get-Command -Type Application ng |
Where-Object { $_.Source -match '\ng$' } |
Remove-Item


Solution

  • Note: The solution below applies analogously to npm - simply replace all occurrences of ng with npm in the command below.

    The implication is that in one of the directories listed in your $env:PATH environment variable there is an extension-less file literally named ng and that the same directory doesn't also contain an ng file with a filename extension that marks it as an executable, i.e. one of the extensions listed in $env:PATHEXT.

    While such a file isn't considered an executable file, PowerShell tries to open it as a document (which is essentially the same as double-clicking a document in File Explorer):

    To solve your problem you need one to two steps: