I set up a fresh angular-app and try to serve it with
ng serve --watch
instead of serving the app a file-editor opens. Why does that happen? How can I resolve this?
this is the editor that shows
Serving with
npm start
works fine
I set up a fresh angular-app and try to serve it with
ng serve --watch
instead of serving the app a file-editor opens. Why does that happen? How can I resolve this?
this is the editor that shows
Serving with
npm start
works fine
Share Improve this question asked Dec 13, 2017 at 8:57 NDDTNDDT 5452 gold badges10 silver badges29 bronze badges 10 | Show 5 more comments4 Answers
Reset to default 11Solution :
Just use npx before any nodejs executables.
Eg : npx ng serve -o
I was able to resolve this by
- unistalling the editor that took the ng-alias
- uninstalling angular-cli
- reinstalling angular-cli
- manually adding the angular-cli alias
I don't know how I got there, but suddenly ng serve
behaved differently and opened the ng.js
file, in the default editor app actually called Editor
. I run a Windows-11 OS.
I fixed the problem by going going to the environment variables menu, removing one of the values for the PATH variable. I removed the following lin, which pointed to my Angular JS:
C:\path\to\node_modules\@angular\cli\bin
- Remove the angular cli path from your environment variables
- Run
npm config get prefix
in your cmd or powershell - Enter the path you get from step 2 into your path environment variable
Dont forget to restart your console
ng
as a command? maybe there's another software or alias that also listens to the ng command – Benedikt Schmidt Commented Dec 13, 2017 at 9:03which ng
on Linux – Benedikt Schmidt Commented Dec 13, 2017 at 10:29