bohoffi / ngx-localstorage

An Angular wrapper for localstorage/sessionstorage access.
https://bohoffi.github.io/ngx-localstorage/
Apache License 2.0
36 stars 14 forks source link

Support Angular 12 #43

Closed Larry-Schultz closed 3 years ago

Larry-Schultz commented 3 years ago

I am currently running angular 12.0.1.

When I attempt to install ngx-localstorage using either the command "ng add ngx-localstorage" or "ng add ngx-localstorage --force" I receive the error message pasted below.

Is the fix just to submit a version of ngx-localstorage to npm that has a dependency for Angular 12 instead of 10? And assuming this works, would you need to do the same thing for Angular 11?

The package ngx-localstorage@3.3.1 will be installed and executed. Would you like to proceed? Yes npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree npm ERR! npm ERR! Found: @angular/core@12.0.1 npm ERR! node_modules/@angular/core npm ERR! peer @angular/core@"12.0.1" from @angular/animations@12.0.1 npm ERR! node_modules/@angular/animations npm ERR! peerOptional @angular/animations@"12.0.1" from @angular/platform-browser@12.0.1 npm ERR! node_modules/@angular/platform-browser npm ERR! peer @angular/platform-browser@"12.0.1" from @angular/forms@12.0.1 npm ERR! node_modules/@angular/forms npm ERR! @angular/forms@"~12.0.1" from the root project npm ERR! 3 more (@angular/platform-browser-dynamic, @angular/router, the root project) npm ERR! @angular/animations@"~12.0.1" from the root project npm ERR! peer @angular/core@"12.0.1" from @angular/common@12.0.1 npm ERR! node_modules/@angular/common npm ERR! peer @angular/common@"12.0.1" from @angular/forms@12.0.1 npm ERR! node_modules/@angular/forms npm ERR! @angular/forms@"~12.0.1" from the root project npm ERR! peer @angular/common@"12.0.1" from @angular/platform-browser@12.0.1 npm ERR! node_modules/@angular/platform-browser npm ERR! peer @angular/platform-browser@"12.0.1" from @angular/forms@12.0.1 npm ERR! node_modules/@angular/forms npm ERR! @angular/forms@"~12.0.1" from the root project npm ERR! 3 more (@angular/platform-browser-dynamic, @angular/router, the root project) npm ERR! 4 more (@angular/platform-browser-dynamic, @angular/router, ...) npm ERR! 7 more (@angular/forms, @angular/platform-browser, ...) npm ERR! npm ERR! Could not resolve dependency: npm ERR! peer @angular/core@"10.2.5" from @angular/platform-browser-dynamic@10.2.5 npm ERR! node_modules/ngx-localstorage/node_modules/@angular/platform-browser-dynamic npm ERR! @angular/platform-browser-dynamic@"^10.1.4" from ngx-localstorage@3.3.1 npm ERR! node_modules/ngx-localstorage npm ERR! ngx-localstorage@"3.3.1" 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!

bohoffi commented 3 years ago

@OtherBrand Thank you for reporting. I guess you're using npm 7.x (which brought the new peer dependency handling)?

You could get around this issue by either downgrading your npm version to the latest 6.x or by installing this lib via npm install instead of ng add.

The problem ist that the Angular CLI does not support the new peer dependency handling coming with npm 7.x as of now - if I'm correct. But as you've used ng add with the --force parameter too it seems that it's still not working.

The libs peer dependencies are declared as follows:

"peerDependencies": {
  "@angular/common": ">=4.0.0",
  "@angular/core": ">=4.0.0"
}

So the lib is already ready for Angular 12.x

Larry-Schultz commented 3 years ago

Thanks for the comment! I was able to install nxg-localstorage using npm, but I had to force it. I used the command npm install ngx-localstorage --force

Larry-Schultz commented 3 years ago

Since it seems to be working now, I'll go ahead and close the issue. Thanks again for the help!