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?
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.
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.
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.
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 .
On Ubuntu, firstly do:
npm install --save-dev
Try:
sudo npm install -g @angular/cli
and then try:
ng serve
This will work 100%.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With