V4 and Native storage error?

Hi

I’m trying v4 and got this problem when importing Native Storage.

Just by adding it to the constructor it fails with an error (check below)

Is it possible to use Native Storage in v4?

ERROR Error: Uncaught (in promise): TypeError: Object(...) is not a function
TypeError: Object(...) is not a function
    at index.js:133
    at Object../node_modules/@ionic-native/native-storage/index.js (index.js:197)
    at __webpack_require__ (bootstrap:81)
    at Object../src/app/home/home.page.ts (home-home-module.js:307)
    at __webpack_require__ (bootstrap:81)
    at Object../src/app/home/home.module.ts (home-home-module.js:232)
    at __webpack_require__ (bootstrap:81)
    at $_lazy_route_resource lazy namespace object:17
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:388)
    at Object.onInvoke (core.js:3824)
    at index.js:133
    at Object../node_modules/@ionic-native/native-storage/index.js (index.js:197)
    at __webpack_require__ (bootstrap:81)
    at Object../src/app/home/home.page.ts (home-home-module.js:307)
    at __webpack_require__ (bootstrap:81)
    at Object../src/app/home/home.module.ts (home-home-module.js:232)
    at __webpack_require__ (bootstrap:81)
    at $_lazy_route_resource lazy namespace object:17
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:388)
    at Object.onInvoke (core.js:3824)
    at resolvePromise (zone.js:814)
    at resolvePromise (zone.js:771)
    at zone.js:873
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421)
    at Object.onInvokeTask (core.js:3815)
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:420)
    at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:188)
    at drainMicroTaskQueue (zone.js:595)

Only at least the 7 times on the forum that I link to the same answer Ionic 4 Beta: Object(...) is not a function

1 Like

Thanks @reedrichards. I hate to be that guy who didn’t search the forum first. I took a look and didn’t find anything because I was sure it was a problem with the storage plugin and not all the plugins.

Not worries, hope your problem is solved now

Not really, I’m attending a different project today, but I tried updating with the following commands

ionic cordova plugin add cordova-plugin-nativestorage@beta ionic cordova plugin add cordova-plugin-nativestorage@5.0.0-beta.16 ionic cordova plugin add cordova-plugin-nativestorage@5.0.0-beta.14

And always I get a “No matching version found for…” error, I’ll try to find documentation about how to update later.

Maybe, if I may, read again the link I linked above. Your problem as nothing to do with cordova itself but how you included ionic-native in your project

I think that Native Storage project is not compatible to ionic v4. The Native Storage source code has not been updated since 2 years.

I have the same issue.

@reedrichards According to your post link, there is no ngx folder in that project native-storage

I think that the Native storage wrapper is there, for Ionic v3 and v4

Can not add this plugin to my app.module. I get “Uncaught TypeError: Object(…) is not a function” error.

nativeStorageError

Node: 8.12.0
ionic (Ionic CLI) : 4.1.2
Ionic Framework : @ionic/angular 4.0.0-beta.7
Cordova 8.0.0
@ionic-native/core”: “^5.0.0-beta.20”
“cordova-plugin-nativestorage”: “^2.3.2”,

I answered this question like a lot of time on the forum, I even linked one of these answers right here in this post, just scroll up and follow “…to the same answer” in my above post

1 Like

npm install @ionic-native/core@beta --save
npm install @ionic-native/native-storage@beta --save

In my case, ionic-native was installed on beta mode, not @ionic-native/native-storage.

4 Likes