ionic-storage: Error: Can't resolve all parameters for Storage: (?, ?).
I’m using @ionic/storage in a non-ionic Angular2 Project. I never noticed this error when using it with Ionic, but I have now seen it while starting 2 Angular2 Projects that make use of the lib.
Error: Can't resolve all parameters for Storage: (?, ?).
I see this runtime error when my app.module.ts is set up as follows:
...
import { Storage } from '@ionic/storage';
@NgModule({
providers: [
Storage,
...
],
...
})
export class AppModule{ }
If I use a custom provider with no special values like this:
...
import { Storage } from '@ionic/storage';
export function provideStorage() {
return new Storage();
}
@NgModule({
providers: [
{ provide: Storage, useFactory: provideStorage },
...
],
...
})
export class AppModule{ }
then everything works no problem. Is this to be expected? From reading the Documentation it doesn’t seem like this should be necessary (and isn’t in my separate Ionic App).
environment details:
angular-cli: 1.0.0-beta.25.5
node: 6.9.3
os: win32 x64
@angular/common: 2.4.5
@angular/compiler: 2.4.5
@angular/core: 2.4.5
@angular/forms: 2.4.5
@angular/http: 2.4.5
@angular/material: 2.0.0-beta.1
@angular/platform-browser: 2.4.5
@angular/platform-browser-dynamic: 2.4.5
@angular/router: 3.4.5
@angular/compiler-cli: 2.4.5
@ionic/storage: 1.1.7
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 8
- Comments: 29 (2 by maintainers)
Hello all, this is now fixed in the new 2.0.0 release 🎉. Instructions here on how to update.
I think the README should be modified somehow to indicate that simply listing
Storage
in the providers array is not guaranteed to work any more, and that the more elaborateuseFactory
approach documented under the “Configuring Storage (new in 1.1.7)” section is mandatory, even if it is as simple as:I believe something in angular-compiler changed somewhere between 2.2 and 4.0.0-beta.5 (perhaps with respect to optional or default parameters), and this is going to start biting people in droves. I tried adding
@Optional
decorators, but it did not seem to help.UPDATE
Potentially related to angular #13609?
Turns out to be a bug within
@ionic/storage
1.1.7. To solve this, open yourpackage.json
and replace"@ionic/storage": "^1.1.7"
with"@ionic/storage": "1.1.6"
. Also don’t forget to runnpm install
.https://forum.ionicframework.com/t/cannot-resolve-all-parameters-for-storage-make-sure-that-all-the-parameters-are-decorated-with-inject-or-have-valid-type-annotations-and-that-storage-is-decorated-with-injectable/47594/4
Hi I’m having
Can't resolve all parameters for Storage: (?).
after update to ionic-storage 2.0.0 Any help regarding this issue?@hsuDev try to use like StorageModule described in http://ionicframework.com/docs/storage/
check https://github.com/MisPlaces/app/blob/master/src/app/app.module.ts#L71
in your case:
try to read docs and all comments in this issue…
this works hope helps someone
@goleary Thank you
@matudelatower nice clean solution.
Just solved my issue of
Can't resolve all parameters for Storage: (?).
.After hours of searching, I found out that I had a component that had
Storage
as a provider. So what I did was removed it.@arturalkaim https://ionicframework.com/docs/storage/