Search code examples
node.jsangularnpmwindows-10

Angular/Visual Studio: "ng is needed... npm is needed"


Using: Windows 10, Visual Studio 2022 17.1.0 (soon to be updated).

I come from the age when I would just copy the JavaScript files of a library in a subfolder of my website/application, add some <script...> tag to the adequate pages and call it installed...

But right now I'm trying to initiate my first Angular 2+ project. I'm trying to start from "Standalone TypeScript Angular Project" template. But Visual Studio won't create my project, it writes in red

ng is needed (...)
npm is needed (...)

So I checked how to install ng... I needed npm, I checked how to install npm... I read it's recommended to install it through nvm... so I installed nmv, then npm, then ng ( v16.15.1 )... but Visual Studio still won't create my project and keeps requiring npm and ng.

What am I missing?

(I tried searching the Internet but mostly found a bunch of unrelated references and dead links.)


Here are the precise things I ran so far:

nvm-setup.exe

(I installed it in a custom folder of D:\ as I want this kind of tools to go there.)

nvm install lts

This installed npm in a subfolder of my customer folder.

npm install -g @angular/cli

This installed ng in a the same folder as npm + a subfolder.


I added '[...]/v16.15.1' (which contains npm.cmd, ng.cmd and node.exe) to the PATH "environment variable", but the problem remains unchanged.


Solved: after previous step, I needed to restart Visual Studio, but as I kept re-launching Visual Studio from Visual Studio Installer, it didn't work as a restart. Effectively closing the Installer and just relaunching Visual Studio refreshed things and it finally worked.


Solution

  • Solved: I needed to add the path that contains npm, ng and node to Windows "user and/or system Environment Variables". And I also needed to restart Visual Studio (including closing Visual Studio Installer).