Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ng serve does not work

I used to have Angular CLI, but I mistakenly installed it again with

npm install -g angular-cli

And now when I run ng serve it complains:

It seems like you're using a project generated using an old version of the Angular CLI.

The latest CLI now uses webpack and includes a lot of improvements, include a simpler workflow, a faster build and smaller bundles.

To get more info, including a step-by-step guide to upgrade the CLI, follow this link: https://github.com/angular/angular-cli/wiki/Upgrading-from-Beta.10-to-Beta.12

When I try to create a new project using ng new in another directory, it complains that:

Cannot find module 'reflect-metadata'

So what is the problem?

like image 997
Sal-laS Avatar asked Sep 29 '16 15:09

Sal-laS


People also ask

Why ng serve command is not working?

To solve the error "ng: command not found", install the angular cli package globally by running npm install -g @angular/cli@latest and restart your terminal. If the command fails, run it with sudo and make sure the correct PATH is set in your system's environment variable.

Why is NG serve taking so long?

This is mostly because of bulky source map files. When you do ng serve , Angular serves the app from memory instead of the dist folder (the file system). This means the entire code (along with map files) will be loaded into the system's memory and this is the main reason why your system or IDE getting slow.

How long does it take to Ng serve?

11), ng serve takes about 1 minute to serve the app, but the ng-serve --source-map=false takes somewhere from 10 to 30 seconds. Moreover, changes are applied much more faster. Save this answer.

How execute ng serve?

ng serve. To get the application running, the ng serve command must execute within the [name-of-app] folder. Anywhere within the folder will do. The Angular CLI must recognize that it is within an environment generated with ng new .


1 Answers

On Ubuntu, firstly do:

npm install --save-dev

Try:

sudo npm install -g @angular/cli

and then try:

ng serve

This will work 100%.

like image 63
shrikant joshi Avatar answered Nov 04 '22 05:11

shrikant joshi