Murilo
Murilo

Reputation: 173

Error in Ionic project: Uncaught Error: Type Storage does not have 'ɵmod' property"

I started a new project in Ionic 6.13.1. So, i added the plugin storage:

ionic cordova plugin add cordova-sqlite-storage

npm install --save @ionic/storage

In app.module.ts i wrote:

import { IonicStorageModule } from '@ionic/storage';

but IonicStorageModule was not recognized, only Storage was.

When i declare Storage in Imports section and run

ionic serve

there was an error: "Uncaught Error: Type Storage does not have 'ɵmod' property".

I did not wrote any other line in code, only this ones.

How can i solve this? Thanks

Upvotes: 1

Views: 3538

Answers (2)

drewjosh
drewjosh

Reputation: 61

I was searching for the same problem, and the previously accepted answer from Rich Tillis is correct, but for beginners like me maybe not obvious:

According to the docs, also linked above, you should do the import in app.module.ts as follows:

Note: pay attention to the import: @ionic/storage-angular So basically everything stays the same, except the import. Well done ionic :)

import { IonicStorageModule } from '@ionic/storage-angular';

@NgModule({
  imports: [
    IonicStorageModule.forRoot()
  ]
})
export class AppModule { }

Upvotes: 1

Rich Tillis
Rich Tillis

Reputation: 1571

For Angular-based Ionic apps using Ionic storage, you have to use the storage-angular library.

npm install @ionic/storage-angular

Here is a link to the Ionic Storage documentation for additional information

Upvotes: 2

Related Questions