Search code examples
visual-studio-codeangular-cli

Angular ng serve asking to open app and not working


Problem Statement

When I try to do ng s -o in my terminal for my Angular app, it says, "How would you like to open this?" inside a popup box where I can choose an app, but choosing an app doesn't work.


Image of Problem

When I try to choose an app, it displays code. When I chose Chrome in the popup box, this happens:

enter image description here

The image shows that when I run an app after ng s -o it just displays code. Also, the tab title in the browser says "ng" when the code shows. Another thing, there is no error in the terminal...


Expected Results

I want to run my Angular app with ng s -o.


Actual Results

The app doesn't serve and asks to open an app.


Note: I am using Visual Studio Code for this.


Solution

  • The problem was related to my cli. I was using PowerShell when I was running ng, and for some strange reason, PowerShell stopped running ng and was asking me to open an app to run the file. Even though this never happened to me before and I was using ng and PowerShell just fine before. Strange!

    Now I am using CMD instead. It now runs perfectly. So, I switched cli's from PowerShell to CMD in my integrated terminal in Visual Studio Code and it started working.

    I got the idea to switch cli's from this: https://github.com/Microsoft/vscode/issues/28541