capacitor-community / sqlite

⚡Capacitor plugin for native & electron SQLite databases.
MIT License
495 stars 118 forks source link

ERROR after migrating to CapacitorV6: TypeError: x is not a function (minimum reproducible example) #574

Closed folsze closed 2 months ago

folsze commented 2 months ago

Describe the bug when I start the app, I get

ERROR TypeError: x is not a function

in the browser console

To Reproduce Steps to reproduce the behavior:

  1. clone this repo: https://github.com/folsze/capacitor-v6-sqlite-x-is-not-a-function
  2. start the app in the desktop browser with npm start
  3. check the console, you will see the error "TypeError: x is not a function"

Expected behavior No error

Screenshots

image

Desktop (please complete the following information):

mehmetozanguven commented 2 months ago

did you find any solution? I am also experiencing the same error in ionic vue application

folsze commented 2 months ago

Sorry no. I ended up downgrading to v5 again.

I thought I needed v6 since I was using capawesome/capacitor-firebase and I thought one of their packages was failing for me because I was using v5 still (according to their docs they only support the latest version, v6). But it turns out this was not the cause, it works with v5.

So maybe this helps you too. Would just need to wait for a new maintainer to arrive. Coincidentally, the maintainer of capawesome offered to maintain this sqlite-plugin now, so maybe he can help once he finds time. I already reached out to him but he does not have time currently. Maybe you can reach out to him again next week? And/or upvote this issue for visibility, anyone who shares the problem

mehmetozanguven commented 2 months ago

Hello, I just found a way to run with Ionic v8. The problem (at least in my case) was the version of the sql.js. Use combatible version of sql.js (1.10.3) and copy the sql-wasm.wasm for the version 1.10.3 Here is the updated version of package.json

{
  "private": true,
  "version": "0.0.1",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "vue-tsc && vite build",
    "preview": "vite preview",
    "test:e2e": "cypress run",
    "test:unit": "vitest",
    "lint": "eslint ."
  },
  "dependencies": {
    "@capacitor-community/sqlite": "^6.0.1",
    "@capacitor/android": "6.1.1",
    "@capacitor/app": "6.0.0",

    "@ionic/vue": "^8.0.0",
    "@ionic/vue-router": "^8.0.0",
    "@types/geojson": "^7946.0.14",
    "@types/leaflet": "^1.9.12",
    "ionicons": "^7.0.0",
    "jeep-sqlite": "^2.7.2",
    "sql.js": "1.10.3", // use specific version
  }
}
folsze commented 2 months ago

Hello, I just found a way to run with Ionic v8. The problem (at least in my case) was the version of the sql.js. Use combatible version of sql.js (1.10.3) and copy the sql-wasm.wasm for the version 1.10.3 Here is the updated version of package.json

{
  "private": true,
  "version": "0.0.1",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "vue-tsc && vite build",
    "preview": "vite preview",
    "test:e2e": "cypress run",
    "test:unit": "vitest",
    "lint": "eslint ."
  },
  "dependencies": {
    "@capacitor-community/sqlite": "^6.0.1",
    "@capacitor/android": "6.1.1",
    "@capacitor/app": "6.0.0",

    "@ionic/vue": "^8.0.0",
    "@ionic/vue-router": "^8.0.0",
    "@types/geojson": "^7946.0.14",
    "@types/leaflet": "^1.9.12",
    "ionicons": "^7.0.0",
    "jeep-sqlite": "^2.7.2",
    "sql.js": "1.10.3", // use specific version
  }
}