Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NgAdd Library Schematic #298

Closed
enzeart opened this issue Dec 27, 2023 · 3 comments
Closed

NgAdd Library Schematic #298

enzeart opened this issue Dec 27, 2023 · 3 comments

Comments

@enzeart
Copy link

enzeart commented Dec 27, 2023

Is your feature request related to a problem? Please describe

I have a project template that attempts to install the package with a script. The installation fails due to incompatible dependencies. Here's a snippet from the error logs:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: @angular/[email protected]
npm ERR! node_modules/@angular/common
npm ERR! @angular/common@"^16.1.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/common@"^17.0.0" from [email protected]
npm ERR! node_modules/ngx-cookie-service
npm ERR! ngx-cookie-service@"*" 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! /Users/enseart/.npm/_logs/2023-12-27T20_50_09_949Z-eresolve-report.txt

Describe the solution you'd like

An ng-add schematic that will install the latest compatible version of the package. I could also optionally add the CookieService provider to a specified module, but that would just be a nice-to-have.

I think this would involve creating a schematic that parses the current package.json, extracts the major version of a core angular dependency (e.g. @angular/core), generates a compatible version spec based on the ngx-cookie-service's versioning scheme, writes the calculated dependency to package.json, and runs the install process.

Support for adding the CookieService provider can be handled by a call to addProviderToModule from @schematics/angular/utility/ast-utils.

Describe alternatives you've considered

I tried the --legacy-peer-deps during installation, but I don't know that ignoring the incompatible peer dependencies is a safe thing to do.

I tried messing around with version ranges, but couldn't get that to work either.

Ultimately, I'd like my project script to make the correct decision about what to install without me have to code explicit versions that won't take into account the angular version the user may currently be using.

Additional context

No response

Copy link

Hello 👋 @enzeart
Thank you for raising an issue. We will investigate into the issue and get back to you as soon as possible. Please make sure you have given us as much context as possible.
Feel free to raise a PR if you can fix the issue

@pavankjadda
Copy link
Collaborator

For Angular 16 use 16.x version

npm i ngx-cookie-service@16

@enzeart
Copy link
Author

enzeart commented Dec 28, 2023

@pavankjadda I don't think we're on the same page. My goal for this feature request is to streamline the process of installing this library in automation.

Ultimately, I'd like my project script to make the correct decision about what to install without me have to code explicit versions that won't take into account the angular version the user may currently be using.

I know that I can manually install a specific version, but that doesn't provide a solution for a generalized project template script. Ideally someone could type ng add ngx-cookie-service and the schematic would install the appropriate version based on the angular version being used by the current project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants