Pravin Kadam
Pravin Kadam

Reputation: 131

Ng serve or ng new does not work

I am getting this message on the terminal, saying that I'm not able to run the app. After enter ng serve to run the Angular application. Please see attached image:

error screenshot

Upvotes: 13

Views: 16588

Answers (3)

Pixsa
Pixsa

Reputation: 599

Simple solution here.

Try:

sudo apt purge ng-common ng-latin

And then, install angular with sudo:

sudo npm install -g @angular/cli

Upvotes: 10

AppDreamer
AppDreamer

Reputation: 1426

I was attempting to setup an Angular 5 "Hello World" app in AWS EC2. After trying and dying in AWS Linux, I decided to use Ubuntu. During my install, the exact same thing kept happening... I would type ng serve, and it would throw me into Mg text editor.

After "fixing it" on one machine (just a ton of trial and error), i then later shelled into my instance from another machine only to have the same thing happen! I finally found a fix.

For each new machine from which you SSH (i use PuTTy), you may have to type the following at least one time...

mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
export PATH=~/.npm-global/bin:$PATH
source ~/.profile

On my second machine, i first checked my path (echo $PATH) and .npm was not showing up. Then after I entered those 4 lines, of course it did... and more importantly... NO MORE Mg Editor! woots. Now I can execute ng serve from a different laptop when needed.

Upvotes: 0

Fredrik Lundin Grande
Fredrik Lundin Grande

Reputation: 8186

1.

Verify that you have the Angular Cli installed globally by running: ng --version. If that command doesn't work, install it by running: npm install -g @angular/cli

2.

Make sure your terminal is open in the directory in the same location as the location of your angular-cli.json file when you run the command.

3.

Make sure you type the right command. I don't really understand what's on the image you attached, but in the bottom of the terminal it says: Mg: server. Could it be that you just misspelled ng with mg?

Upvotes: -2

Related Questions