Skip to content

Vue3 use better-sqlite3 get error with 'promisify is not a function' #888

@Sylor-huang

Description

@Sylor-huang

My package.json is:

 "dependencies": {
    "@element-plus/icons-vue": "^2.0.10",
    "@esbuild-plugins/node-globals-polyfill": "^0.1.1",
    "autoprefixer": "^10.4.12",
    "better-sqlite3": "^7.6.2",
    "element-plus": "^2.2.17",
    "js-cookie": "^3.0.1",
    "moment-mini": "^2.24.0",
    "path": "^0.12.7",
    "postgres": "^3.2.2",
    "tailwindcss": "^3.1.8",
    "unplugin-auto-import": "^0.7.2",
    "unplugin-vue-components": "^0.19.5",
    "vue": "^3.2.25",
    "vue-router": "^4.0.15",
    "vuex": "^4.0.2",
  },
  "devDependencies": {
    "@vitejs/plugin-vue": "^2.3.3",
    "sass": "^1.52.1",
    "unplugin-element-plus": "^0.4.0",
    "vite": "^3.1.6"
  }

My node is v16.14.0 and node-gyp had been installed

When I import in js file, and I will get error

import Database from 'better-sqlite3';
// errors

TypeError: promisify is not a function
    at node_modules/better-sqlite3/lib/methods/backup.js (backup.js:6:18)
    at __require2 (chunk-64WWFUG7.js?v=35f1f87c:18:50)
    at node_modules/better-sqlite3/lib/database.js (database.js:72:29)
    at __require2 (chunk-64WWFUG7.js?v=35f1f87c:18:50)
    at node_modules/better-sqlite3/lib/index.js (index.js:2:18)
    at __require2 (chunk-64WWFUG7.js?v=35f1f87c:18:50)
    at dep:better-sqlite3:1:16

I had found a similar issue, but sorry, I don't know how it is resolved

#848

Thanks for your help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions