Npm install version conflict after migration to Angular 12

Product/components used and version/fix level:

Backend: 1020.296.0
UI: 1011.0.4

Detailed explanation of the problem:

Hi it’s Luca,
this is a followup from this post.

We would like to upgrade our custom app Cockpit based UI version to latest. The idea is to proceed step by step so first is to go from web sdk version 11 to 12.

I followed this receip:

  1. c8ycli new atc cockpit -a @c8y/apps@1011.45.0

The files changed by the above commands are:

image

In particular this is the new package.json:

{
  "name": "dashboard",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "dependencies": {
    "@angular/animations": "12.2.4",
    "@angular/cdk": "12.2.4",
    "@angular/common": "12.2.4",
    "@angular/compiler": "12.2.4",
    "@angular/core": "12.2.4",
    "@angular/forms": "12.2.4",
    "@angular/platform-browser": "12.2.4",
    "@angular/platform-browser-dynamic": "12.2.4",
    "@angular/router": "12.2.4",
    "@angular/upgrade": "12.2.4",
    "@c8y/ngx-components": "1011.45.0",
    "@ngx-translate/core": "13.0.0",
    "rxjs": "~6.6.3",
    "zone.js": "~0.11.4",
    "@c8y/ng1-modules": "1011.45.0",
    "angular": "1.6.9",
    "@c8y/style": "1011.45.0"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "12.2.4",
    "@angular/compiler-cli": "12.2.4",
    "@angular/language-service": "12.2.4",
    "@angular/localize": "12.2.4",
    "@types/webpack": "^5.28.0",
    "file-loader": "^6.2.0",
    "typescript": "4.2.4",
    "@c8y/cli": "1011.45.0"
  },
  "scripts": {
    "start": "c8ycli server",
    "build": "c8ycli build",
    "deploy": "c8ycli deploy",
    "postinstall": "ngcc"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "c8y": {
    "application": {
      "name": "atc",
      "contextPath": "atc",
      "key": "atc-application-key",
      "tabsHorizontal": true,
      "upgrade": true,
      "rightDrawer": true,
      "breadcrumbs": false,
      "sensorAppOneLink": "http://onelink.to/pca6qe",
      "sensorPhone": true,
      "contentSecurityPolicy": "base-uri 'none'; default-src 'self' 'unsafe-inline' http: https: ws: wss:; connect-src 'self' http: https: ws: wss:;  script-src 'self' open.mapquestapi.com *.twitter.com *.twimg.com *.aptrinsic.com 'unsafe-inline' 'unsafe-eval' data:; style-src * 'unsafe-inline' blob:; img-src * data:; font-src * data:; frame-src *; worker-src 'self' blob:;",
      "dynamicOptionsUrl": "/apps/public/public-options/options.json"
    },
    "cli": {}
  }
}

When i run npm install I get:

Any suggestion?

Error messages / full error message screenshot / log file:

Question related to a free trial, or to a production (customer) instance?

Hi Luca,

just because angular 12 is supported starting from version 1011.45.0 of the Web SDK, this might not be the best option to upgrade to. If you want to do this step by step, I would recommend to upgrade from major version to the next major version.
The versions with minor version 0 (x.0.y) are the ones that actually went into production and received further fixes, so these are probably the best options to upgrade to.
So e.g.

  1. Upgrade to 1013.0.437
  2. Upgrade to 1014.0.427
  3. Upgrade to 1015.0.536
  4. Upgrade to 1016.0.483
  5. Upgrade to 1017.0.522
  6. Upgrade to 1018.0.260

In general it should not be a lot harder to directly upgrade to 1018.

Regards,
Tristan

1 Like

Also don’t forget to use the correct node version when migrating.
1018.0.260 should be Angular 15 → node ^14.20.0 || ^16.13.0 || ^18.10.0

1 Like

As suggested by Tristan I upgraded directly to 1018.0.240. I’m using node 16.13.0

However after

c8ycli new atc cockpit -a @c8y/apps@1018.0.240

And deleting node_modules and running:

npm install

I run into this:

code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: atc@1.0.0
npm ERR! Found: @angular-devkit/build-angular@0.1101.4
npm ERR! node_modules/@angular-devkit/build-angular
npm ERR!   dev @angular-devkit/build-angular@"14.0.6" from the root project
npm ERR!   peer @angular-devkit/build-angular@"<0.1200.0 >=0.1100.0" from @c8y/cli@1011.0.15
npm ERR!   node_modules/@c8y/cli
npm ERR!     dev @c8y/cli@"1018.0.240" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! dev @angular-devkit/build-angular@"14.0.6" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: @angular/compiler-cli@14.0.6
npm ERR! node_modules/@angular/compiler-cli
npm ERR!   peer @angular/compiler-cli@"^14.0.0" from @angular-devkit/build-angular@14.0.6
npm ERR!   node_modules/@angular-devkit/build-angular
npm ERR!     dev @angular-devkit/build-angular@"14.0.6" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! See /home/luca/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/luca/.npm/_logs/2024-05-17T07_49_57_971Z-debug.log

I need some help pls

Hi Luca,

have you removed your node_modules folder before running npm install? Also ensure that you are not having a dependency on @angular-devkit/build-angular in version 0.1101.4 in your package.json.

In case this does not resolve the issue, please provide your current package.json file.

Regards,
Tristan

Hi tristan,

have you removed your node_modules folder before running npm install ?

Yes I did

Also ensure that you are not having a dependency on @angular-devkit/build-angular in version 0.1101.4 in your package.json .

mmm nope, however I provide the package.json:

{
  "name": "atc",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "dependencies": {
    "@angular/animations": "14.0.6",
    "@angular/cdk": "14.1.2",
    "@angular/common": "14.0.6",
    "@angular/compiler": "14.0.6",
    "@angular/core": "14.0.6",
    "@angular/forms": "14.0.6",
    "@angular/platform-browser": "14.0.6",
    "@angular/platform-browser-dynamic": "14.0.6",
    "@angular/router": "14.0.6",
    "@angular/upgrade": "14.0.6",
    "@c8y/client": "1018.0.240",
    "@c8y/ngx-components": "1018.0.240",
    "@ngx-translate/core": "14.0.0",
    "ngx-bootstrap": "9.0.0",
    "rxjs": "~6.6.3",
    "zone.js": "~0.11.7",
    "@c8y/ng1-modules": "1018.0.240",
    "angular": "1.6.9",
    "@c8y/style": "1018.0.240"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "14.0.6",
    "@angular/compiler-cli": "14.0.6",
    "@angular/language-service": "14.0.6",
    "@angular/service-worker": "14.0.6",
    "@angular/localize": "14.0.6",
    "@types/jest": "^28.1.6",
    "jest": "^28.1.3",
    "jest-preset-angular": "^12.2.5",
    "typescript": "4.7.4",
    "@c8y/cli": "1018.0.240"
  },
  "scripts": {
    "start": "c8ycli server",
    "build": "c8ycli build",
    "deploy": "c8ycli deploy",
    "locale-extract": "c8ycli locale-extract",
    "postinstall": "ngcc",
    "test": "jest"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "c8y": {
    "application": {
      "name": "atc",
      "contextPath": "atc",
      "key": "atc-application-key",
      "tabsHorizontal": true,
      "upgrade": true,
      "rightDrawer": true,
      "breadcrumbs": false,
      "sensorAppOneLink": "http://onelink.to/pca6qe",
      "sensorPhone": true,
      "contentSecurityPolicy": "base-uri 'none'; default-src 'self' 'unsafe-inline' http: https: ws: wss:; connect-src 'self' http: https: ws: wss: data:;  script-src 'self' *.bugherd.com *.twitter.com *.twimg.com *.aptrinsic.com 'unsafe-inline' 'unsafe-eval' data:; style-src * 'unsafe-inline' blob:; img-src * data: blob:; font-src * data:; frame-src *; worker-src 'self' blob:;",
      "dynamicOptionsUrl": "/apps/public/public-options/options.json",
      "contextHelp": true
    },
    "cli": {}
  }
}

What I dont understand is this:

npm ERR! Found: @angular-devkit/build-angular@0.1101.4

where that version comes from. I cleaned the npm cache as well btw.

A bit of backgound. This project is a clone of another project running the old version 10.11. I copy pasted the whole project directory, included package-lock.json and package.json. Then I upgraded the SDK web version to 10.18.

From the logs it sounds like you are still having @c8y/cli@1011.0.15 installed…
Did you install @c8y/cli in version 1018.0.240 globally before trying to scaffold the application?
Maybe try running npm i -g @c8y/cli@1018.0.240 and the try to scaffold the new application once again…

1 Like