NDDT
NDDT

Reputation: 545

ng-serve command opens editor

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

Upvotes: 5

Views: 13701

Answers (4)

Silvan
Silvan

Reputation: 369

  1. Remove the angular cli path from your environment variables
  2. Run npm config get prefix in your cmd or powershell
  3. Enter the path you get from step 2 into your path environment variable

Dont forget to restart your console

Upvotes: 0

Makan
Makan

Reputation: 2756

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

Upvotes: 4

AKSHAY AGRAWAL
AKSHAY AGRAWAL

Reputation: 111

Solution :

Just use npx before any nodejs executables.

Eg : npx ng serve -o

Upvotes: 11

NDDT
NDDT

Reputation: 545

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

Upvotes: 4

Related Questions