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:
@mklement0 I tried reinstalling: Node.js PowerShell-7.2.3-win-x64
Problem solved, using :
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:
Look for files literally named ng
(no filename extension) in the directories listed in $env:PATH
and remove them:
# Note: This may require running from an ELEVATED session (as admin).
# IMPORTANT:
# -WhatIf *previews* the deletion.
# Remove it, once the output shows the file(s) you want to remove.
Get-Command -Type Application ng |
Where-Object { $_.Source -match '\\ng$' } |
Remove-Item -WhatIf
ng
executable (a file whose extension is one of the extensions listed in $env:PATHEXT
, such as .exe
or .cmd
) may then surface, from another directory listed in $env:PATH
, which the extension-less ng
file may have shadowed.If no such executable surfaces, you'll have to (re)install the desired ng
application.