luifon
luifon

Reputation: 198

Only Visual Studio Code doesn't recognize "ng" command

I saw that there a lot of questions regarding ng not being recognized by the computer, but my problem isn't exactly that.

Every single piece of software that has a command shell recognizes ng, only vs code doesn't.

IntelliJ? Check.

Git bash? Check.

Windows command prompt? Check.

VS Code? Nope.

Using npm run ng makes it work, but this is super annoying and not how it should be working.

For reference, ng is in my path already, it looks like this right now:

C:\Users\username\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng

Any reasons why it's working everywhere but on VS code?

Upvotes: 1

Views: 9039

Answers (3)

Ariel
Ariel

Reputation: 31

I had that problem, my VS-code terminal didn't run ng commands. My terminal doesn't run ng serve.

I removed the file "ng.ps1" from "C:\Users\PC\AppData\Roaming\npm"

ng.ps1 file in "C:\Users\PC\AppData\Roaming\npm".

And now, my VS-code terminal runs ng commands. My terminal runs ng serve.

P.S. I had the same problem with tsc (type-script), and when I removed tsc.ps1, my terminal started to run tsc commands.

Upvotes: 1

Schwertfisch
Schwertfisch

Reputation: 143

1- Press Ctrl+Shift+P to show all commands.
2- Type shell in the displayed text box to filter the list.
3- Select Terminal: Select Default Shell.
4- You will be prompted to Select your preferred terminal shell, you can change this 
   later in your settings or follow the same process as we do now
5- Select Command Prompt (cmd.exe)
6- Click the Delete Icon in the shell pane to remove the existing terminal.
7- Press Ctrl +back tick(which is the character before the number one in your keyboard) 
   (or View > Terminal in menu) to open a new terminal pane

Upvotes: 0

luifon
luifon

Reputation: 198

Figured out the problem: I was using powershell inside VS Code instead of using CMD.

Edit: Also, to use it in powershell I needed to use the command "Set-ExecutionPolicy Unrestricted"

Upvotes: 2

Related Questions