_Original issue by @serhii-kachailov on 2019-05-23T19:59:29Z_
When adding @ionic-native/sqlite plugin (https://ionicframework.com/docs/native/sqlite/) to the @ionic/react (0.0.5) project following the installation steps:
ionic cordova plugin add cordova-sqlite-storage
npm install @ionic-native/sqlite
Getting an error "Cannot find module '@angular/core': / Can't resolve '@angular/core' in '/Users/serhiikachailov/ef/hydra/node_modules/@ionic-native/sqlite/ngx'`
### Full error:
index.js:1 Uncaught Error: Cannot find module '@angular/core'
at webpackMissingModule (index.js:1)
at Module.../../node_modules/@ionic-native/sqlite/ngx/index.js (index.js:1)
at __webpack_require__ (bootstrap:786)
at fn (bootstrap:149)
at Module../src/sql-lite-repositories/current-user.tsx (current-user.tsx:1)
at __webpack_require__ (bootstrap:786)
at fn (bootstrap:149)
at Module../src/context/auth.tsx (tour-list.tsx:52)
at __webpack_require__ (bootstrap:786)
at fn (bootstrap:149)
at Module../src/components/sign-in-form.tsx (menu.tsx:50)
at __webpack_require__ (bootstrap:786)
at fn (bootstrap:149)
at Module../src/pages/front/Login.tsx (Wishlist.tsx:49)
at __webpack_require__ (bootstrap:786)
at fn (bootstrap:149)
at Module../src/App.tsx ( groupOptions: {} namespace object:665)
at __webpack_require__ (bootstrap:786)
at fn (bootstrap:149)
at Module../src/index.tsx (auth.tsx:78)
at __webpack_require__ (bootstrap:786)
at fn (bootstrap:149)
at Object.0 (routing.tsx:32)
at __webpack_require__ (bootstrap:786)
at checkDeferredModules (bootstrap:45)
at Array.webpackJsonpCallback [as push] (bootstrap:32)
at main.chunk.js:1
webpackMissingModule @ index.js:1
../../node_modules/@ionic-native/sqlite/ngx/index.js @ index.js:1
__webpack_require__ @ bootstrap:786
fn @ bootstrap:149
./src/sql-lite-repositories/current-user.tsx @ current-user.tsx:1
__webpack_require__ @ bootstrap:786
fn @ bootstrap:149
./src/context/auth.tsx @ tour-list.tsx:52
__webpack_require__ @ bootstrap:786
fn @ bootstrap:149
./src/components/sign-in-form.tsx @ menu.tsx:50
__webpack_require__ @ bootstrap:786
fn @ bootstrap:149
./src/pages/front/Login.tsx @ Wishlist.tsx:49
__webpack_require__ @ bootstrap:786
fn @ bootstrap:149
./src/App.tsx @ groupOptions: {} namespace object:665
__webpack_require__ @ bootstrap:786
fn @ bootstrap:149
./src/index.tsx @ auth.tsx:78
__webpack_require__ @ bootstrap:786
fn @ bootstrap:149
0 @ routing.tsx:32
__webpack_require__ @ bootstrap:786
checkDeferredModules @ bootstrap:45
webpackJsonpCallback @ bootstrap:32
(anonymous) @ main.chunk.js:1
index.js:1375 /Users/serhiikachailov/ef/hydra/node_modules/@ionic-native/sqlite/ngx/index.js
Module not found: Can't resolve '@angular/core' in '/Users/serhiikachailov/ef/hydra/node_modules/@ionic-native/sqlite/ngx'
Any solution or alternatives? Adding the '@angular/core' to the project is kinda missing the point of using @ionic/react on the first place.
How are you importing the module in your files? It should be: import { SQLite, SQLiteObject } from '@ionic-native/sqlite'; without /ngx at the end. The documentation lacks some information about that.
$ ionic cordova plugin add cordova-sqlite-storage
[ERROR] Ionic doesn't support using Cordova with @ionic/react projects.
We encourage you to try Capacitor (https://ion.link/capacitor)
So the question is how to use sqllite with capacitor?
Most helpful comment
How are you importing the module in your files? It should be:
import { SQLite, SQLiteObject } from '@ionic-native/sqlite';without/ngxat the end. The documentation lacks some information about that.