Using ng --version
I got:
@angular/cli: 1.0.0
which is not the latest release available.
Since I have Angular CLI globally installed on my system, in order to upgrade it I tried:
npm update angular-cli -g
But it does not work, because it stays to 1.0.0 version.
After reading some issues reported on the GitHub repository, I found the solution.
In order to update the angular-cli package installed globally in your system, you need to run:
npm uninstall -g @angular/cli
npm install -g @angular/cli@latest
Depending on your system, you may need to prefix the above commands with sudo
.
Also, most likely you want to also update your local project version, because inside your project directory it will be selected with higher priority than the global one:
rm -rf node_modules
npm uninstall --save-dev @angular/cli
npm install --save-dev @angular/cli@latest
npm install
thanks grizzm0 for pointing this out on GitHub.
After updating your CLI, you probably want to update your Angular version too.
Note: if you are updating to Angular CLI 6+ from an older version, you might need to read this.
Edit: In addition, if you were still on a 1.x version of the cli, you need to convert your angular-cli.json
to angular.json
, which you can do with the following command (check this for more details):
ng update @angular/cli --from=1.7.4 --migrate-only
npm install -g @angular/cli
npm install -g @angular/cli@latest
ng --version
or Angular 14.X +
ng version
See documentation.
ng6+ -> 7.0
Update RxJS (depends on RxJS 6.3)
npm install -g rxjs-tslint
rxjs-5-to-6-migrate -p src/tsconfig.app.json
Remove rxjs-compat
Then update the core packages and Cli:
ng update @angular/cli @angular/core
(Optional: update Node.js to version 10 which is supported in NG7)
ng6+ (Cli 6.0+): features simplified commands
First, update your Cli
npm install -g @angular/cli
npm install @angular/cli
ng update @angular/cli
Then, update your core packages
ng update @angular/core
If you use RxJS, run
ng update rxjs
It will update RxJS to version 6 and install the rxjs-compat
package under the hood.
If you run into build errors, try a manual install of:
npm i rxjs-compat
npm i @angular-devkit/build-angular
Lastly, check your version
ng v
Note on production build:
ng6 no longer uses intl
in polyfills.ts
//remove them to avoid errors
import 'intl';
import 'intl/locale-data/jsonp/en';
ng5+ (Cli 1.5+)
npm install @angular/{animations,common,compiler,compiler-cli,core,forms,http,platform-browser,platform-browser-dynamic,platform-server,router}@next [email protected] rxjs@'^5.5.2'
npm install [email protected] --save-exact
Note:
After updating both the global and local package, clear the cache to avoid errors:
npm cache verify (recommended)
npm cache clean (for older npm versions)
Here are the official references:
The following approach worked for me:
npm uninstall -g @angular/cli
then
npm cache verify
then
npm install -g @angular/cli
I work on Windows 10, sometimes I had to use: npm cache clean --force
as well. You don't need to do if you don't have any problem during the installation.
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