Transitioning from Angular 13 to the latest iteration, Angular 14

My current project is built on Angular version 13, and I've been tasked with upgrading it to version 16.

After researching on Stack Overflow and checking the official documentation, I learned that the recommended upgrade path is to go from 13 -> 14 first.

However, when following the instructions provided in the docs, I encountered a recurring error every time I tried to run the project:

The CLI version installed only supports Angular versions ^13.0.0 || ^13.3.0-rc.0,
while the project is on Angular version 14.3.0.
To resolve this issue, please refer to the following link for guidance on updating Angular:

https://update.angular.io/

Per the documentation, I ran the command

ng update @angular/core@14 @angular/cli@14
and globally installed Angular CLI version 14 as instructed.

Upon running npm run ng version, here's the output I received:

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 14.2.10
Node: 18.16.1 (Unsupported)
Package Manager: npm 10.8.2
OS: win32 x64

Angular: 14.3.0
... animations, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, platform-server, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1303.11
@angular-devkit/build-angular   13.3.11
@angular-devkit/core            13.3.11
@angular-devkit/schematics      14.2.10
@angular/cdk                    13.3.9
@angular/material               13.3.9
@nguniversal/express-engine     13.1.1
@schematics/angular             14.2.10
rxjs                            7.8.1
typescript                      4.6.3

Answer №1

It appears that you currently have a mixture of Angular 13 and Angular 14 versions installed.

I recommend installing the latest 13.x versions for @angular-devkit/schematics, @schematics/angular, and any other Angular 14.x packages you may have already installed (including CLI).

You can achieve this by running

npm i @angular-devkit/schematics@13 @schematics/angular@13
for all packages currently using version v14.x. Afterwards, proceed with upgrading them as usual.

In situations like this, I usually utilize the project's installed Angular CLI to handle the update process to prevent errors. The Angular CLI is smart enough to select a newer version for performing the upgrade.

To do this, run:

npm run ng update @angular/cli@14 @angular/core@14

This command will use the project's Angular CLI v13 to execute the update, which will automatically download and apply a compatible version if needed.

This method eliminates the need for installing a global Angular CLI :)

Personally, I prefer not to install anything globally to avoid complications when working on multiple projects

Answer №2

For those looking to update Angular, check out the Official Angular Update Guide here:

All you have to do is select your current angular version in the "from" field and the version you want to upgrade to in the "to" field, then click on the "Show me how upgrade!" button. The site will guide you through the upgrade process step by step.

Best of luck!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What are the ways in which Angular can offer assistance to Internet Explorer 9?

The news is out - the Angular team has just announced their support for Internet Explorer 9! This revelation has left me wondering, how is it even possible? Currently, I am an avid user of AngularJS and have dedicated time to studying its ins and outs. Fr ...

The Angular2 website is failing to update properly when utilizing Angular2-cli

Currently, I am in the process of developing a small Angular2 app and I am using WebStorm to make modifications to a file in order to see the updates reflect in my browser. So far, everything seems to be error-free as I have executed the following command ...

Having trouble getting Angular2 to start with npm?

After running the npm start command in the terminal, I encountered an error that doesn't seem to have a solution in the other posts I viewed. This is the specific error message I received: https://i.sstatic.net/gnTS5.png I attempted to resolve the i ...

Prevent Ionic 2 hardware back button from triggering default action

Is there a way to prevent the default navigation when tapping the hardware back button? I attempted using registerBackButtonAction, but it ends up overriding the behavior of the back button on every page, which is not desired. I also tried this method: d ...

Dealing with API responses in Angular 2

Hello there! I am a beginner in Angular 2 and might ask some basic questions, so please bear with me. I am struggling to understand how to handle an API response. Below is my NodeJS Server API function (which has been checked and is working fine): router ...

Service consuming in Angular 2 using Stomp protocol

Why am I seeing responseBody as undefined, but I am able to see the subscribe response in msg_body? What could be causing this issue with responseBody? let stomp_subscription = this._stompService.subscribe('/topic/queue'); stomp_subscription.ma ...

Mastering the art of constraining TypeScript function parameters using interface properties

Hey there, I've been exploring ways to restrict a function parameter so that it only accepts "strings" related to interface properties, similar to what I achieved in the validate fields function: Please note: The TypeScript code provided here is simp ...

Recover an Angular project following a git checkout operation

Being a beginner in Angular development, I have a query regarding the management of data stored in the Git repository created by Angular CLI. After initializing a new Angular workspace with ng new helloworld, using Angular CLI version 7.2.1, a Git reposito ...

What is the process for moving information between files?

I have two files which are named as, employee-rates-controller.ts: private load() { return this.entityService .load(this.$scope.projectRevisionUid) .then(resp => { localStorage.removeItem('employeerates'); this.$ ...

Utilize Pipe for every instance of a variable in the Controller

In my controller, I have multiple requests (POST, GET etc.) where the path includes an id parameter that needs to be a number string. I want to validate this parameter once and have it apply to all instances. Here is the current code snippet: @Get(&apo ...

Guide on removing a key from an object in TypeScript

My variable myMap: { [key: string]: string[] } = {} contains data that I need to modify. Specifically, I am trying to remove a specific value associated with a certain key from the myMap. In this case, my goal is to delete value1 from myMap[Key1]. Despit ...

Subscribe to a new Observable once the previous one completes

I need assistance in getting the current user after logging in. When I use this.router.navigate([this.returnUrl]); it does not work. Can someone please help me identify what is wrong here and how I can fix it? onSubmit(): void { this.authService.logi ...

How can I adjust the indentation in Angular Prime-ng's p-tree component?

In my project, I am utilizing the primg-ng tree component for the sidebar. Currently, the output is displayed as shown here: https://i.stack.imgur.com/kcSQt.png However, I am looking to maintain consistent indentation levels without any adaptive changes ...

How to choose cypress elements that are text-free using Cypress

Currently, I am troubleshooting an issue with a dropdown menu that allows for invalid selections. Despite being labeled as "unavailable," users are still able to click on these options for the product. <select readonly="" class="size-sele ...

Storing multiple email addresses in an array using an HTML input element

I have a small React Bootstrap form where I am trying to save multiple email addresses entered by the user into an array. However, when I use onChange={()=> setEmails(e.target.value as any} it stores them in string format like this --> [email p ...

Typescript UniqueForProp tool not working as expected

I've created a utility function called UniqueForProp that takes an array of objects and a specified property within the object. It then generates a union type containing all possible values for that property across the array: type Get<T, K> = K ...

How can the map function be executed sequentially every second, using async functions, fetch API, and promises, without running in parallel?

I am facing an issue with my map function, as it needs to fetch data from an online API that only allows one request per second. I attempted to solve this problem by implementing the following code: const sleep = (ms: number) => { return new Promise(( ...

Highcharts - running out of space for tooltips – what's the solution? Show only the tooltip for the series being hovered over, or adjust the layout to accommodate all tooltips

I am facing an issue where not all of the tooltips on my chart are displayed when hovering, as shown in the image provided. Specifically, the tooltip for the green series is missing. https://i.sstatic.net/QcbWV.png Upon researching, I discovered that Hig ...

Issue with package: Unable to locate the module specified as './artifacts/index.win32-ia32-msvc.node'

I am encountering an issue while using Parcel for the first time. When I execute npx parcel .\app\index.html, I receive the following error: Error: Module not found './artifacts/index.win32-ia32-msvc.node' Require stack: - C:\Users ...

How can I use a custom pipe from an Angular library in my project?

I am encountering a problem when trying to import a custom pipe from an Angular library into the main app. This pipe is part of a custom library and I am using the static forRoot approach to load the library's module. I have declared and exported the ...