goetzrobin / spartan

Cutting-edge tools powering Angular full-stack development.
https://spartan.ng
MIT License
1.1k stars 121 forks source link

Peer dependencies causing problem - multiple versions of ui-core #263

Closed elfoxus closed 2 months ago

elfoxus commented 2 months ago

Please provide the environment you discovered this bug in.

Windows 11, npm 10.2.4, node 21.6.0, angular 17 cli

Which area/package is the issue in?

Don't know / other

Description

Hi. After installing spartan components following tutorial I cannot run npm install. I've noticed that some components have different versioning than the others, i.e. 0.0.1-alpha.344 and 0.0.1-alpha.343. It might be causing problems. I dont think that using angular cli made any changes, cause same thing happened with nx.

What might be the solution to this topic? Not using components with old version so no mismatch is happening? Thanks for help.

 code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: frontend@0.0.0
npm ERR! Found: @spartan-ng/ui-core@0.0.1-alpha.344
npm ERR! node_modules/@spartan-ng/ui-core
npm ERR!   @spartan-ng/ui-core@"0.0.1-alpha.344" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @spartan-ng/ui-core@"0.0.1-alpha.343" from @spartan-ng/ui-checkbox-brain@0.0.1-alpha.344
npm ERR! node_modules/@spartan-ng/ui-checkbox-brain
npm ERR!   @spartan-ng/ui-checkbox-brain@"0.0.1-alpha.344" 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.

Please provide the exception or error you saw

No response

Other information

No response

I would be willing to submit a PR to fix this issue

elfoxus commented 2 months ago

After removing some spartang-ng libraries I could run npm i, however I cannot use some of the components 😢 What's been left in my project.json:

"@spartan-ng/ui-accordion-brain": "0.0.1-alpha.344",
    "@spartan-ng/ui-avatar-brain": "^0.0.1-alpha.344",
    "@spartan-ng/ui-collapsible-brain": "^0.0.1-alpha.344",
    "@spartan-ng/ui-command-brain": "^0.0.1-alpha.344",
    "@spartan-ng/ui-core": "^0.0.1-alpha.344",
    "@spartan-ng/ui-label-brain": "^0.0.1-alpha.344",
    "@spartan-ng/ui-menu-brain": "^0.0.1-alpha.344",
    "@spartan-ng/ui-progress-brain": "^0.0.1-alpha.344",
    "@spartan-ng/ui-radiogroup-brain": "^0.0.1-alpha.344",
    "@spartan-ng/ui-separator-brain": "^0.0.1-alpha.344",
    "@spartan-ng/ui-toggle-brain": "^0.0.1-alpha.344",

Other automatically installed libs have been removed so that npm install would not throw the exceptions without --legacy-peer-deps. I'm not really sure what's causing those problems.

@edit:

I think that some of the libs after version update to 0.0.1-alpha.344 still have dependency to ui-core in version 0.0.1-alpha.343, for example:

{
  "name": "@spartan-ng/ui-accordion-brain",
  "version": "0.0.1-alpha.344",
  "peerDependencies": {
    "@angular/core": "^17.3.0",
    "@angular/cdk": "^17.3.0",
    "@spartan-ng/ui-core": "0.0.1-alpha.343"
  },
  "dependencies": {
    "tslib": "^2.3.0"
  },
  "sideEffects": false,
  "publishConfig": {
    "access": "public"
  },
  "module": "fesm2022/spartan-ng-ui-accordion-brain.mjs",
  "typings": "index.d.ts",
  "exports": {
    "./package.json": {
      "default": "./package.json"
    },
    ".": {
      "types": "./index.d.ts",
      "esm2022": "./esm2022/spartan-ng-ui-accordion-brain.mjs",
      "esm": "./esm2022/spartan-ng-ui-accordion-brain.mjs",
      "default": "./fesm2022/spartan-ng-ui-accordion-brain.mjs"
    }
  }
}

I think this is easy fix for library, but every release should be took care of that, so no mismatches are deployed.

After I corrected all peer dependency versions to .344 in package-lock.json which was generated with npm i --legacy-peer-deps --package-lock-only I can run npm i smoothly, but be cautious about this issue. :)

And by the way - what is the procedure of updating generated components by cli in upcoming versions?

DevWedeloper commented 2 months ago

This happened to me too when installing @spartan-ng/ui-dialog-brain (with other spartan brains already existing), currently relying on running npm install --legacy-peer-deps until a fix occurs.

goetzrobin commented 2 months ago

This issue was addressed as part of releases: cli 0.0.1-alpha.350 & ui 0.0.1-alpha.347. Let me know if it still occurs