Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Cannot find module '@mapbox/node-pre-gyp' in electron When i build it #1713

Closed
lzz29 opened this issue Aug 9, 2023 · 0 comments
Closed

Comments

@lzz29
Copy link

lzz29 commented Aug 9, 2023

Issue Summary

Platform: Mac M1 13.5
node.js:16.2.0
package.json

{
  "name": "test03",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint",
    "electron:build": "vue-cli-service electron:build",
    "electron:serve": "vue-cli-service electron:serve",
    "postinstall": "electron-builder install-app-deps",
    "postuninstall": "electron-builder install-app-deps"
  },
  "main": "background.js",
  "dependencies": {
    "core-js": "^3.8.3",
    "rebuild": "^0.1.2",
    "sqlite3": "^5.1.6",
    "vue": "^3.2.13"
  },
  "devDependencies": {
    "@babel/core": "^7.12.16",
    "@babel/eslint-parser": "^7.12.16",
    "@electron/rebuild": "^3.2.13",
    "@vue/cli-plugin-babel": "~5.0.0",
    "@vue/cli-plugin-eslint": "~5.0.0",
    "@vue/cli-service": "~5.0.0",
    "electron": "^13.0.0",
    "electron-devtools-installer": "^3.1.0",
    "eslint": "^7.32.0",
    "eslint-plugin-vue": "^8.0.3",
    "vue-cli-plugin-electron-builder": "~2.1.1"
  },
  "eslintConfig": {
    "root": true,
    "env": {
      "node": true
    },
    "extends": [
      "plugin:vue/vue3-essential",
      "eslint:recommended"
    ],
    "parserOptions": {
      "parser": "@babel/eslint-parser"
    },
    "rules": {}
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not dead",
    "not ie 11"
  ]
}

This is the easiest demo.
In development mode, I can use sqlite3, but after building, After opening the software, an error will be prompted.
I have tried many methods, but there is still no solution.

Relevant logs or output

Uncaught Exception:
Error: Cannot find module '@mapbox/node-pre-gyp'
Require stack:
- /Users/jin/www/test03/dist_electron/mac-arm64/test03.app/Contents/Resources/app.asar/node_modules/sqlite3/lib/sqlite3-binding.js
- /Users/jin/www/test03/dist_electron/mac-arm64/test03.app/Contents/Resources/app.asar/node_modules/sqlite3/lib/sqlite3.js
- /Users/jin/www/test03/dist_electron/mac-arm64/test03.app/Contents/Resources/app.asar/background.js
- 
at Module._resolveFilename (internal/modules/cjs/loader.js:887:15)
at Function.n._resolveFilename (electron/js2c/browser_init.js:257:1128)
at Module._load (internal/modules/cjs/loader.js:732:27)
at Function.f._load (electron/js2c/asar_bundle.js:5:12913)
at Module.require (internal/modules/cjs/loader.js:959:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/Users/jin/www/test03/dist_electron/mac-arm64/test03.app/Contents/Resources/app.asar/node_modules/sqlite3/lib/sqlite3-binding.js:1:16)
at Module._compile (internal/modules/cjs/loader.js:1078:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1108:10)
at Module.load (internal/modules/cjs/loader.js:935:32)

Version

5.1.6

Node.js Version

16.2

How did you install the library?

no

daniellockyer added a commit that referenced this issue Dec 24, 2023
…stall`

fixes #1641
fixes #1721
fixes #1714
fixes #1713
fixes #1700
fixes #1704

- `@mapbox/node-pre-gyp` is effectively unmaintained [1] as has a few bugs
  which our users keep running into
- it seems the prebuilt binary world has moved in favor of prebuild +
  it's various other forms
- one option would be to use prebuildify to bundle all binaries into the
  package, but that's a step too far removed from the current situation
  for now
- instead, we can use prebuild-install to download the binaries, and
  `prebuild` to build + upload the binaries
- this means we can remove node-pre-gyp and fix a bunch of issues!

[1]: mapbox/node-pre-gyp#657
daniellockyer added a commit that referenced this issue Dec 24, 2023
…stall`

fixes #1641
fixes #1721
fixes #1714
fixes #1713
fixes #1700
fixes #1704

- `@mapbox/node-pre-gyp` is effectively unmaintained [1] as has a few bugs
  which our users keep running into
- it seems the prebuilt binary world has moved in favor of prebuild +
  it's various other forms
- one option would be to use prebuildify to bundle all binaries into the
  package, but that's a step too far removed from the current situation
  for now
- instead, we can use prebuild-install to download the binaries, and
  `prebuild` to build + upload the binaries
- this means we can remove node-pre-gyp and fix a bunch of issues!
- eventually, we could start providing electron prebuilt binaries too

[1]: mapbox/node-pre-gyp#657
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant