I'm trying to use ionic/storage-angular
in my ionic application. I was following the documentation: https://github.com/ionic-team/ionic-storage.
I installed storage-angular (npm install @ionic/storage-angular
) but I'm getting this error when importing IonicStorageModule
in my app.module:
../../node_modules/@ionic/storage-angular/fesm2020/ionic-storage-angular.mjs:2:0-51 Error: Module not found: Error: Can't resolve '@angular/common' in '/home/<path_to_my_project>/node_modules/@ionic/storage-angular/fesm2020'
In app.module.ts I just did:
import { IonicStorageModule } from '@ionic/storage-angular';
imports: [ ... IonicStorageModule.forRoot()]
I'm using this version:
Ionic CLI : 7.2.0 (/home/baffo/.nvm/versions/node/v20.11.0/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/angular 7.6.6
@angular-devkit/build-angular : 17.1.1
@angular-devkit/schematics : 17.1.1
@angular/cli : 17.1.1
@ionic/angular-toolkit : 9.0.0
I tried this solution, but didn't work: https://stackoverflow.com/a/64717548/10946588
Well I don't know how exactly I fixed it but:
angular.json
(following this solution):"projects": {
"app": {
"build": {
"options": {
"allowedCommonJsDependencies": [
"rxjs-compat",
"localforage"
],
I revert all the changes of package.json
and package.json.lock
and removed node_module
folder.
Then, I reinstalled everything again:
npm install
npm install --save @ionic/storage
npm install --save @ionic/storage-angular
And it's working now.