I recently updated all my projects to Angular 14, but when I tried to install a package using `npm i`, it still

The challenge at hand

I encountered an issue with my two Angular projects. The first project serves as a library utilized by the second project. I recently upgraded both projects to Angular 14 following this guide.

However, after running an npm i on the second project, I was surprised to see that it still required Angular 3 for the library, which left me puzzled and unable to resolve the discrepancy.

Here is the error message displayed when executing npm i in the second project:

While resolving: <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="50333f3d203f3e353e247d333f3f3b39352310617e61607e60">[email protected]</a>
Found: @angular/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6704080a0a080927565349544957">[email protected]</a>
node_modules/@angular/common
  @angular/common@"^14.3.0" from the root project

Could not resolve dependency:
peer @angular/common@"~13.1.2" from @xxx/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7f13161d0d1e0d063f4e514e4b47514f520d1c514c4b4c4946">[email protected]</a>
node_modules/@xxx/library
  @xxx/library@"1.148.0-rc.34369" from the root project

Fix the upstream dependency conflict, or retry
this command with --force or --legacy-peer-deps
to accept an incorrect (and potentially broken) dependency resolution.

This section highlights the configuration within the package.json of the library:

{
  "name": "xxx-library",
  "version": "1.148.0",
    ... more content here
}

Similarly, below are the details from the package.json of the second project:

{
  "name": "component-cookies",
  "version": "1.10.0",
   ... various scripts and dependencies listed
}

The strategies employed

To tackle this dilemma, I experimented with several solutions:

  1. Deleting the package-lock.json file from both projects before running npm i again.
  2. Removing the package-lock.json, node-modules, and .angular/cache directories prior to re-executing npm i.
  3. Erasing the local project entirely and reinstalling everything from the remote branch afresh.
  4. Upgrading the Node version locally from 16 to 18.
  5. Scouring through the library's package-lock.json to identify any dependencies linked to Angular 13.

Note:

Upon inspecting the library's package-lock.json, I noticed only one dependency pointing towards Angular 13:

...
    some relevant information from package-lock.json
...

Despite reviewing additional resources confirming no issues, the library continues to request Angular 13 upon installation in the second project, raising confusion regarding the matter due to the absence of other Angular 13 references in the package-lock file.

Recent developments

Ran npm ls @angular/common resulting in:

<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="555b5bb54e51536b49505f48583d52535148745746495e7646540b09544e51">[email protected]</a>
Some directory paths and Angular versions listed here

Answer №1

Upon further investigation, I found that the projects contained nested projects, each with its own package.json file. Unfortunately, when using the ng update angular command, it only updated the Angular version in the first package.json file. This meant manually changing the Angular version in all of the nested project's package.json files.

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 is the method for executing the command "npm test" through the WebStorm file watcher feature?

How can I set up npm test to automatically run whenever a file changes in Webstorm? I'm aware of creating a run configuration from NPM but prefer not having to trigger it manually each time. ...

Issue encountered while attempting to install a previous version of cordova

Hello, I am currently attempting to install an older version of cordova. Specifically, I am looking for version 2.2.0 and here is what I have done so far: npm uninstall -g cordova npm install -g <a href="/cdn-cgi/l/email-protection" class="__cf_email__ ...

Failed to decipher an ID token from firebase

I'm feeling extremely frustrated and in need of assistance. My goal is to authenticate a user using Google authentication so they can log in or sign up. Everything worked perfectly during development on localhost, but once I hosted my app, it stopped ...

In Javascript, determine the root cause of a boolean expression failing by logging the culprit

Within my JavaScript code, I have a complex predicate that comprises of multiple tests chained together against a value. I am looking for a way to log the specific location in the expression where it fails, if it does fail. Similar to how testing librarie ...

Running a locally installed npm package using npx: A step-by-step guide

My folder structure contains the locally installed Cypress module: cypress-test-project node_modules cypress tests.spec.js In an informative article, it was mentioned that npx allows for easy execution of both globally and locally installed pack ...

Looking for a SSR Component to Choose Dates?

In the process of designing a landing page, I encountered a challenge with incorporating a date picker feature. My goal is to have users select a date and then be redirected to another page upon clicking a button. The technology stack includes NextJS where ...

A comprehensive guide to resolving installation issues with vue.js

Hello there! I'm currently facing an issue while trying to install vue.js on my linux mint using npm. When I follow the instructions provided in the vue tutorial and run this simple command: npm install -g @vue/cli Despite receiving some warnings, I ...

Setting default selections for mat-select component in Angular 6

I've been attempting to preselect multiple options in a mat-select element, but I haven't been successful so far. Below is the snippet of HTML code: <mat-dialog-content [formGroup]="form"> <mat-form-field> <mat-select pla ...

Why does the same command in NPM produce different results?

What occurs when you repeatedly run the command "npm install -g cordova ionic" to install packages in nodejs? Are there any potential problems or issues that could arise from this? Or does it simply recognize that the package is already installed and noth ...

Understanding the tsconfig.json file in an Angular project

I encountered the following error in my tsconfig.ts file: 'No inputs were found in config file 'c:/Projects/Angular2//src/tsconfig.json'. Specified 'include' paths were '["src/**/*.ts"]' and 'exclude' paths ...

Is it necessary to specify the inputs property when defining an Angular @Component?

While exploring the Angular Material Button code, I came across something interesting in the @Component section - a declared inputs property. The description indicates that this is a list of class property names to data-bind as component inputs. It seems ...

Are the dependencies of a Node module not updating properly after being updated or installed?

I recently integrated react-highcharts into my application. After using npm install react-highcharts, the installation was successful, but with a warning message: found 1 high severity vulnerability, run `npm audit fix` to fix them, or `npm audit` for deta ...

When attempting to transfer data from the parent component to child components, the data is appearing as undefined in the display

I have been working on passing data from a parent component to child components, but I keep encountering an issue where the data is showing as undefined. Below is the code snippet: Parent Component In this section, I have declared the variable part_data ...

Encountered a TypeError in Angular printjs: Object(...) function not recognized

I'm currently working on integrating the printJS library into an Angular project to print an image in PNG format. To begin, I added the following import statement: import { printJS } from "print-js/dist/print.min.js"; Next, I implemented the pri ...

Utilizing a file type validator in SurveyJs: A guide

Is there a way to validate uploaded documents on a form using surveyJs and typescript with a custom validator before the file is uploaded? The current issue I am facing is that the validator gets called after the upload, resulting in an API error for unsup ...

Encountering an error in Cytoscape using Angular and Typescript: TS2305 - Module lacks default export

I am working on an Angular app and trying to integrate Cytoscape. I have installed Cystoscape and Types/cytoscape using npm, but I encountered an error when trying to import it into my project. To troubleshoot, I started a new test project before implement ...

Tips for preventing CORS and SSL issues when using localhost

Attempting to log in with Google on my Svelte app involves sending a request to an Express server. However, I encounter different errors on different browsers. On Firefox, I receive a Cross-Origin Request Blocked: The Same Origin Policy disallows reading t ...

Utilize Angular roles to sort and organize website data

Exploring the utilization of login roles in my Angular SPA application which operates solely on the client side, integrated with Spring Security and Spring Boot. I have concerns about potential unauthorized access by a skilled developer who could manipula ...

When using Angular 2, the array.splice() function is causing the elements to be removed from the

I am currently working with an HTML table that has default checked rows. <table> <tr> <th></th> <th>Id</th> <th>Name</th> <th>Initial</th> </tr> ...

The 'Alias[]' type does not share any properties with the 'Alias' type

I encountered an issue: The error message 'Type 'Alias[]' has no properties in common with type 'Alias'' appeared. Here is my Alias setup: alias: Alias = { id: 0, domain_id: 0, source: '', dest ...