In this post, we will discuss how to upgrade the angular version. Here is the guide to updating the Angular v14 to v15.
Angular 15 supports node.js version 18.12.1 and TypeScript version 4.8 and above.
You have to update your Angular version outside of your Angular project. Move out of your project and update the angular version globally.
Update Angular CLI to upgrade the Angular Version to the latest release. For example, if your angular version is 14, first uninstall the Angular CLI through the npm command and then reinstall it to upgrade the Angular version.
Steps
1. Uninstall Angular CLI
Command
npm uninstall -g @angular/cli
Output
removed 209 packages, and audited 1 package in 27s
found 0 vulnerabilities
2. Clean Cache
Command
npm cache clean --force
Output
npm WARN using --force Recommended protections disabled.
3. Verify Cache
Command
npm cache verify
Output
Cache verified and compressed (~\AppData\Local\npm-cache\_cacache)
Content verified: 0 (0 bytes)
Index entries: 0
Finished in 0.028s
4. Install Angular CLI
Command
npm install -g @angular/cli
Output
npm WARN deprecated @npmcli/move-file@2.0.1: This functionality has been moved to @npmcli/fs
npm WARN deprecated sourcemap-codec@1.4.8: Please use @jridgewell/sourcemap-codec instead
added 232 packages, and audited 233 packages in 57s
26 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
5. Check the Angular Version
Command
ng version
Output
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 15.0.4
Node: 18.12.1
Package Manager: npm 8.19.2
OS: win32 x64
Angular: undefined
...
Package Version
------------------------------------------------------
@angular-devkit/architect 0.1500.4 (cli-only)
@angular-devkit/core 15.0.4 (cli-only)
@angular-devkit/schematics 15.0.4 (cli-only)
@angular/material 14.2.6
@schematics/angular 15.0.4 (cli-only)
In Angular v14, if a non-compatible node.js version is used the below warning will be shown.
Warning: The current version of Node (18.12.1) is not supported by Angular.
To clear this warning, either downgrade the node.js version or upgrade the Angular version to the next release.
After upgrading Angular version, create a new project to view the new Angular version dependencies in package.json. Angular 15 application package.json will look like this,
package.json
{
"name": "sample-project15",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test"
},
"private": true,
"dependencies": {
"@angular/animations": "^15.0.0",
"@angular/common": "^15.0.0",
"@angular/compiler": "^15.0.0",
"@angular/core": "^15.0.0",
"@angular/forms": "^15.0.0",
"@angular/platform-browser": "^15.0.0",
"@angular/platform-browser-dynamic": "^15.0.0",
"@angular/router": "^15.0.0",
"rxjs": "~7.5.0",
"tslib": "^2.3.0",
"zone.js": "~0.12.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "^15.0.4",
"@angular/cli": "~15.0.4",
"@angular/compiler-cli": "^15.0.0",
"@types/jasmine": "~4.3.0",
"jasmine-core": "~4.5.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.0.0",
"typescript": "~4.8.2"
}
}