I have an Angular project and if I want to start the project with 'ng serve' it is opening the ng file from
C:\Users{user}\AppData\Roaming\npm\node_modules\@angular\cli\bin
Also, I can start the project with 'npm start'.
Remove path "C:\Users{user}\AppData\Roaming\npm\node_modules@angular\cli\bin" from Environment variable - path. It worked for me.
The problem was that I use ng in powershell. In cmd work..
I had a similar problem where typing ng in terminal open ng.js in vscode so my fix to it in Environment Variable remove any angular path in system variable and in user variable add this path C:\Users\Here\AppData\Roaming\npm don't forget to add your system name in the (Here)
Here the quick way to solve the problem.You can add script command to package.json as below
"scripts": {
....
"create":"ng g c components/auth-extensions"
}
and run the command
npm run create
Once your job is done, you can delete the command from package.json.
This avoids installing global package, environment variable, path etc..
ng new YourProjectNameto create a project andng serveto run.