electron / rebuild

Package to rebuild native Node.js modules against the currently installed Electron version
MIT License
1.02k stars 175 forks source link

electron-rebuild failure with sqlite3 #204

Open trogers1 opened 6 years ago

trogers1 commented 6 years ago

Hello all,

Thank you so much for all your hard work on this. I'm sure I will love it once I get it working.

Firstly, housekeeping. I'm using electron 1.7.9 sqlite3 3.1.13 electron-rebuild 1.6.0. macOS Sierra 10.12.6 npm 5.4.2 node 8.7.0

I was just trying to build a simple test-application by following this video and, before that, this video.

I could get neither to work.

Here is the error I got:

$ npm run rebuild

> sqlitetrial2@1.0.0 rebuild /Users/<name>/Documents/#Coding/InlandNewsRecorder/Electron/SQLiteTrial2
> electron-rebuild -f -w sqlite3

✖ Rebuild Failed

An unhandled error occurred inside electron-rebuild
action_after_build.target.mk:6: *** missing separator.  Stop.
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/<name>/Documents/#Coding/InlandNewsRecorder/Electron/SQLiteTrial2/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack     at emitTwo (events.js:125:13)
gyp ERR! stack     at ChildProcess.emit (events.js:213:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Darwin 16.7.0
gyp ERR! command "/usr/local/Cellar/node/8.7.0/bin/node" "/Users/<name>/Documents/#Coding/InlandNewsRecorder/Electron/SQLiteTrial2/node_modules/.bin/node-gyp" "rebuild" "--target=1.7.9" "--arch=x64" "--dist-url=https://atom.io/download/electron" "--build-from-source" "--module_name=node_sqlite3" "--module_path=/Users/<name>/Documents/#Coding/InlandNewsRecorder/Electron/SQLiteTrial2/node_modules/sqlite3/lib/binding/electron-v1.7-darwin-x64" "--host=https://mapbox-node-binary.s3.amazonaws.com" "--remote_path=./{name}/v3.1.13/{toolset}/" "--package_name=electron-v1.7-darwin-x64.tar.gz"
gyp ERR! cwd /Users/<name>/Documents/#Coding/InlandNewsRecorder/Electron/SQLiteTrial2/node_modules/sqlite3
gyp ERR! node -v v8.7.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok

Failed with exit code: 1

Error: action_after_build.target.mk:6: *** missing separator.  Stop.
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/<name>/Documents/#Coding/InlandNewsRecorder/Electron/SQLiteTrial2/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack     at emitTwo (events.js:125:13)
gyp ERR! stack     at ChildProcess.emit (events.js:213:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Darwin 16.7.0
gyp ERR! command "/usr/local/Cellar/node/8.7.0/bin/node" "/Users/<name>/Documents/#Coding/InlandNewsRecorder/Electron/SQLiteTrial2/node_modules/.bin/node-gyp" "rebuild" "--target=1.7.9" "--arch=x64" "--dist-url=https://atom.io/download/electron" "--build-from-source" "--module_name=node_sqlite3" "--module_path=/Users/<name>/Documents/#Coding/InlandNewsRecorder/Electron/SQLiteTrial2/node_modules/sqlite3/lib/binding/electron-v1.7-darwin-x64" "--host=https://mapbox-node-binary.s3.amazonaws.com" "--remote_path=./{name}/v3.1.13/{toolset}/" "--package_name=electron-v1.7-darwin-x64.tar.gz"
gyp ERR! cwd /Users/<name>/Documents/#Coding/InlandNewsRecorder/Electron/SQLiteTrial2/node_modules/sqlite3
gyp ERR! node -v v8.7.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok

Failed with exit code: 1
    at SafeSubscriber._error (/Users/<name>/Documents/#Coding/InlandNewsRecorder/Electron/SQLiteTrial2/node_modules/spawn-rx/lib/src/index.js:277:84)
    at SafeSubscriber.__tryOrUnsub (/Users/<name>/Documents/#Coding/InlandNewsRecorder/Electron/SQLiteTrial2/node_modules/rxjs/Subscriber.js:238:16)
    at SafeSubscriber.error (/Users/<name>/Documents/#Coding/InlandNewsRecorder/Electron/SQLiteTrial2/node_modules/rxjs/Subscriber.js:197:26)
    at Subscriber._error (/Users/<name>/Documents/#Coding/InlandNewsRecorder/Electron/SQLiteTrial2/node_modules/rxjs/Subscriber.js:128:26)
    at Subscriber.error (/Users/<name>/Documents/#Coding/InlandNewsRecorder/Electron/SQLiteTrial2/node_modules/rxjs/Subscriber.js:102:18)
    at MapSubscriber.Subscriber._error (/Users/<name>/Documents/#Coding/InlandNewsRecorder/Electron/SQLiteTrial2/node_modules/rxjs/Subscriber.js:128:26)
    at MapSubscriber.Subscriber.error (/Users/<name>/Documents/#Coding/InlandNewsRecorder/Electron/SQLiteTrial2/node_modules/rxjs/Subscriber.js:102:18)
    at SafeSubscriber._next (/Users/<name>/Documents/#Coding/InlandNewsRecorder/Electron/SQLiteTrial2/node_modules/spawn-rx/lib/src/index.js:251:65)
    at SafeSubscriber.__tryOrUnsub (/Users/<name>/Documents/#Coding/InlandNewsRecorder/Electron/SQLiteTrial2/node_modules/rxjs/Subscriber.js:238:16)
    at SafeSubscriber.next (/Users/<name>/Documents/#Coding/InlandNewsRecorder/Electron/SQLiteTrial2/node_modules/rxjs/Subscriber.js:185:22)
npm ERR! code ELIFECYCLE
npm ERR! errno 255
npm ERR! sqlitetrial2@1.0.0 rebuild: `electron-rebuild -f -w sqlite3`
npm ERR! Exit status 255
npm ERR!
npm ERR! Failed at the sqlitetrial2@1.0.0 rebuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/<name>/.npm/_logs/2017-10-19T04_25_41_870Z-debug.log

Any ideas? I followed both videos exactly as instructed and ran into issues for each. I'm lost!

Thank you so much for your help.

epver commented 6 years ago

I found it, it is the “https://atom.io/download/electron” url, has no related package

trogers1 commented 6 years ago

@iunfire I'm sorry for responding about a month and a half later, but such is life.

Is there something I can do about this? The link obviously leads to a download for atom. Is there anything we can do about it? It still isn't working.

developeryashraj commented 6 years ago

@trogers1 i was facing the same issue. Just add this script in your package.json.

"postinstall": "electron-builder install-app-deps",

Then do npm run postinstall. This should rebuild native dependencies. After this change i am now successfully able to run npm run dev. Version that i have is as below.

"devDependencies": {
    "electron": "^1.7.10",
    "electron-builder": "^19.50.0"
}

Just give it a try. I found this at:- https://github.com/electron-userland/electron-builder/issues/2294. As per this reference, electron-rebuild is not required if we are using electron-builder.

trogers1 commented 6 years ago

@developeryashraj I tried that and it didn't work for me. I...

{
  "name": "sqlitetrial2",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "electron .",
    "rebuild": "electron-rebuild -f -w sqlite3",
    "postinstall": "electron-builder install-app-deps"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "sqlite3": "^3.1.13"
  },
  "devDependencies": {
    "electron": "^1.7.10",
    "electron-builder": "^19.50.0",
    "electron-rebuild": "^1.6.0"
  }
}

Does that look any different from yours? I'm getting pretty much the same error. I think it may have to do with sqlite3? Are you using that as well? Do you have a link to your project, so I can see what appears different?

developeryashraj commented 6 years ago

Here is my package.json.

{
"dependencies": {
    "axios": "^0.17.1",
    "d3": "^4.10.2",
    "electron-is-dev": "^0.3.0",
    "electron-updater": "^2.17.6",
    "mqtt": "^2.15.0",
    "ncp": "^2.0.0",
    "react": "^15.6.2",
    "react-dom": "^15.6.2",
    "react-notify-toast": "^0.4.0",
    "react-redux": "^5.0.6",
    "react-router-dom": "^4.2.2",
    "react-tap-event-plugin": "^3.0.2",
    "redux": "^3.7.2",
    "redux-thunk": "^2.2.0",
    "sqlite3": "^3.1.13",
    "sqlite3-transactions": "0.0.5",
    "verbose": "^0.2.3"
  }, 
"scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "rebuild": "electron-rebuild -f -w sqlite3",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject",
    "electron": "electron .",
    "postinstall": "electron-builder install-app-deps",
    "electron:build": "electron-builder",
    "dev": "nf start -p 3001",
    "electron-pack": "build --em.main=build/electron.js",
    "preelectron-pack": "npm run build"
  },
  "devDependencies": {
    "electron": "^1.7.10",
    "electron-builder": "^19.50.0",
    "electron-rebuild": "^1.6.0",
    "foreman": "^2.0.0",
    "react-scripts": "0.8.5"
  }
} 

There is no such difference with your package.json. And Yes i am using sqlite3 as well. Previously getting same error that you have posted earlier but after doing this i'm not getting any error related to sqlite3 rebuild. This is what i did

Hope this helps :)

trogers1 commented 6 years ago

@developeryashraj Thank you so much for your help, though it doesn't appear to work for me. However, knowing that this solution works for someone means that it's likely something wrong with my code. I'll update if/when I resolve the issue. At least I know your steps should work!

NikunjChotaliya commented 6 years ago

@trogers1 you need to install all dependency for sqlite3, like visual studio, python etc. or you can install it by single npm command ,just try it npm install -g windows-build-tools it will install all dependency for in windows.

then build sqlite3 with electron-rebuild. put this command to script in your package.json. "rebuild": "electron-rebuild -f -w sqlite3"

Let me know if you have any issue.

emcodest commented 6 years ago
  1. Download electronjs of your platform choice. This must correspond with the nodejs architecture platform.
    • npm install --platform=win32 electron npm install --arch=ia32 electron
  2. install sqlite3, && run electron builder It works.
dmr commented 6 years ago

Thank you for the "windows-build-tools" hint!

ilkerulutas commented 6 years ago

I had a similar problem, it seems python bin directory was not in my PATH, which was causing problems.

valleygtc commented 6 years ago

@NikunjChotaliya Why it doesn't work for me. I run: npm install -g windows-build-tools then: add "rebuild": "electron-rebuild -f -w sqlite3" in my package.json. then run npm rebuild. It's fine. But it generate a file "[sqlite3] Success: "D:\code\Mynote\node_modules_sqlite3@4.0.2@sqlite3\lib\binding\node-v57-win32-x64\node_sqlite3.node" already installed"

not file "node_modules_sqlite3@4.0.2@sqlite3\lib\binding\electron-v2.0-win32-x64\node_sqlite3.node". So when I run npm start, there is still error: "electron-v2.0-win32-x64\node_sqlite3.node" file not found. My OS is Windows7. Can somebody help me?

coconutbox commented 6 years ago

Same to me! windows 10 npm v6.4.1 sqlite3 v4.0.0.2 electron v3.0.0 electron-rebuild v1.8.2

i have node_modules/sqlite3/lib/binding/node-v64-win32-x64/node_sqlite3.node, but need node_modules/sqlite3/lib/binding/electron-v3.0-win32-x64/node_sqlite3.node

TinyChou commented 5 years ago

@NikunjChotaliya Why it doesn't work for me. I run: npm install -g windows-build-tools then: add "rebuild": "electron-rebuild -f -w sqlite3" in my package.json. then run npm rebuild. It's fine. But it generate a file "[sqlite3] Success: "D:\code\Mynote\node_modules_sqlite3@4.0.2@sqlite3\lib\binding\node-v57-win32-x64\node_sqlite3.node" already installed"

not file "node_modules_sqlite3@4.0.2@sqlite3\lib\binding\electron-v2.0-win32-x64\node_sqlite3.node". So when I run npm start, there is still error: "electron-v2.0-win32-x64\node_sqlite3.node" file not found. My OS is Windows7. Can somebody help me?

You may run npm run rebuild instead of npm rebuild.

tyrants666 commented 5 years ago

npm --add-python-to-path='true' --debug install --global windows-build-tools https://github.com/felixrieseberg/windows-build-tools/issues/56#issuecomment-308739624

wuno commented 5 years ago

@coconutbox I have the exact issue as you. Did you find a solution to this?

cokuna-pavelkosolapov commented 5 years ago

@coconutbox I have the exact issue as you. Did you find a solution to this?

@wuno, you just need to build sqlite binary for an actual electron version

Works for me:

$ node-gyp rebuild --arch=ia32 --target_platform=win32 --dist-url=https://atom.io/download/atom-shell --module_name=node_sqlite3 --module_path=../lib/binding/electron-v3.0-win32-ia32 --target=3.0.0 --msvs_version=2015

Note, if you will upgrade your libraries, you may need to rebuild the sqlite binaries for the current version of tools.

P.S.: it was me, i wrote from @coconutbox account.

bantynigam commented 4 years ago

@trogers1 you need to install all dependency for sqlite3, like visual studio, python etc. or you can install it by single npm command ,just try it npm install -g windows-build-tools it will install all dependency for in windows.

then build sqlite3 with electron-rebuild. put this command to script in your package.json. "rebuild": "electron-rebuild -f -w sqlite3"

Let me know if you have any issue.

This worked for me. Thank you.

i-chaochen commented 3 years ago

Same here!

electron cannot find the sqlite3 module and rebuild the sqlite3 failed.

Regarding the window-build-tools, how to rebuild it on MacOS?

i-chaochen commented 3 years ago

Tried to postinstall

❯ npm run postinstall

> electron_project@1.0.0 postinstall
> electron-builder install-app-deps

  • electron-builder  version=22.9.1
  • rebuilding native dependencies  dependencies=sqlite3@5.0.1 platform=darwin arch=x64

But still the same

Uncaught Error: Cannot find module '.../node_modules/sqlite3/lib/binding/napi-v6-darwin-x64/node_sqlite3.node'
lavchandaria commented 3 years ago

@i-chaochen Did you got the solution for the error you are getting?

Umar-Juraev commented 1 year ago

Hi , i have ⨯ cannot find prebuild-install
⨯ cannot execute cause=exit status error . it is end of the error  ELIFECYCLE  Command failed with exit code 1.

                command=/opt/homebrew/Cellar/pnpm/7.13.5/libexec/bin/pnpm.cjs rebuild better-sqlite3@7.6.2
                workingDir=

 ELIFECYCLE  Command failed with exit code 1.

ramit-mitra commented 1 year ago

Hey all, just wanted to add here that am facing the same issue when trying to install SQLite3 for my electron app. Am using MacOS 13.3.1 (22E261) running on M2 (platform=darwin arch=arm64). Hoping someone with similar system config is able to solve it and help me out here. Thanks.