sajivkumar / mathjax-angular

Mathjax 3 for angular
10 stars 13 forks source link

installation issues with angular 15 project #33

Open mratanusarkar opened 4 months ago

mratanusarkar commented 4 months ago

following up with issue #27, after PR #30, the expectation was that mathjax-angular 2.2.1 would be compatible with all angular versions 17 and below!

but currently getting the following error with my Angular 15 project, and the issue still stays unresolved as mentioned in #27

error stack on npm i mathjax-angular:

>npm i mathjax-angular
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: app@0.0.0
npm ERR! Found: @angular/common@15.2.10
npm ERR! node_modules/@angular/common
npm ERR!   @angular/common@"^15.2.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/common@"^17.1.3" from mathjax-angular@2.2.1
npm ERR! node_modules/mathjax-angular
npm ERR!   mathjax-angular@"*" 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!
npm ERR! For a full report see:
npm ERR! C:\Users\Atanu sarkar\AppData\Local\npm-cache\_logs\2024-07-10T14_08_51_553Z-eresolve-report.txt

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Atanu sarkar\AppData\Local\npm-cache\_logs\2024-07-10T14_08_51_553Z-debug-0.log
kussmaul commented 2 months ago

I have Angular 18 and tried mathjax-angular for the first time today. I got a similar message, which went away when I overrode the dependencies (in package.json):

  "overrides": {
    "mathjax-angular": {
      "@angular/common": "^18.0.2",
      "@angular/core": "^18.0.2"
    }
  },

You could try overriding with your current Angular version...

mratanusarkar commented 2 months ago

@kussmaul thanks! it works with this override! I'm curious if this has any side effects, or may introduce issues in the future. and if this falls under angular best practices.

mratanusarkar commented 2 months ago

for anyone reading @kussmaul's suggestion, and confused on where to put the "overrides" in package.json, here is how your package.json will look like: (eg: for Angular 15)

{
  "name": "project-name",
  "version": "0.0.0",
  "scripts": {...},
  "private": true,
  "dependencies": {
    ...
    "@angular/common": "^15.2.0",
    "@angular/compiler": "^15.2.0",
    "@angular/core": "^15.2.0",
    ...
    "mathjax-angular": "^2.1.1",
    ...
    "zone.js": "~0.12.0"
  },
  "devDependencies": {...},
  "overrides": {
    "mathjax-angular": {
      "@angular/common": "^15.2.0",
      "@angular/core": "^15.2.0"
    }
  }
}

[source]

kussmaul commented 2 months ago

@kussmaul thanks! it works with this override! I'm curious if this has any side effects, or may introduce issues in the future. and if this falls under angular best practices.

@mratanusarkar, I'm not an expert on this, but problems would arise if mathjax-angular truly can't run with your overridden version (e.g., incompatible API calls). You should review the override when you update things and remove it when no longer needed.

mratanusarkar commented 2 months ago

You should review the override when you update things and remove it when no longer needed.

the place where I am using this library is based on Angular 15. as of now, your suggested change works fine! so, I will go with it. Thanks!

It's just updating the parent angular dependency version and no changes to the library itself. anyway, I will keep a watch if anything breaks.