After installing the Zip plugin
ionic cordova plugin add cordova-plugin-zip
npm install @ionic-native/zip
and importing in app.module.ts
import { Zip } from '@ionic-native/zip/ngx';
I got the following error:
ERROR in ./src/app/app.module.ts
[ng] Module not found: Error: Can’t resolve ‘@ionic-native/zip/ngx’
If I try to import as ‘@ionic-native/zip’:
Uncaught TypeError: Object(…) is not a function
Am I missing something?
In my case the problem was that, initially, I installed a previous version of the plugin because I ended up using the Ionic v3 documentation:
$ ionic cordova plugin add cordova-plugin-zip
$ npm install --save @ionic-native/zip@4
However, even when I reversed this situation using:
$ ionic cordova plugin rm cordova-plugin-zip
$ npm uninstall @ionic-native/zip@4
something unexpected happened that did not update package.json
. So when I tried to install the newer version, it always ends up using the folder structure of the old version (without /ngx), which generated the error. To fix this I just removed all entries related to this plugin from the package.json
file and then installed everything again.
1 Like