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

prebuilt demo not working when building for electron #24

Open
addlistener opened this issue Nov 9, 2022 · 1 comment
Open

prebuilt demo not working when building for electron #24

addlistener opened this issue Nov 9, 2022 · 1 comment

Comments

@addlistener
Copy link

addlistener commented Nov 9, 2022

The prebuilt/demo works locally on my mac. However when I yarn add ../path/to/addon to another project and run electron-builder it failed

Use node16.16.0 and electron 19.0.9

$ node-pre-gyp install --fallback-to-build
      CXX(target) Release/obj.target/native_rt/native-rt.o
      CXX(target) Release/obj.target/native_rt/native-rt.o
      CXX(target) Release/obj.target/native_rt/native-rt_mac.o
    Failed to execute '/path/to/user/.nvm/versions/node/v16.16.0/bin/node /path/to/project/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/path/to/project/node_modules/native_rt/lib/binding/Release/electron-v19.0-darwin-x64/native_rt.node --module_name=native_rt --module_path=/path/to/project/node_modules/native_rt/lib/binding/Release/electron-v19.0-darwin-x64' (1)
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
      SOLINK_MODULE(target) Release/native_rt.node
      COPY /path/to/project/node_modules/native_rt/lib/binding/Release/electron-v19.0-darwin-x64/native_rt.node
      TOUCH Release/obj.target/action_after_build.stamp

                    errorOut=node-pre-gyp info it worked if it ends with ok
    node-pre-gyp info using [email protected]
    node-pre-gyp info using [email protected] | darwin | x64
    node-pre-gyp http GET https://nodeaddons.s3-us-west-2.amazonaws.com/native_rt/v1.0.1/Release/native_rt-v1.0.1-electron-v19.0-darwin-x64.tar.gz
    node-pre-gyp http 403 https://nodeaddons.s3-us-west-2.amazonaws.com/native_rt/v1.0.1/Release/native_rt-v1.0.1-electron-v19.0-darwin-x64.tar.gz
    node-pre-gyp ERR! Tried to download(403): https://nodeaddons.s3-us-west-2.amazonaws.com/native_rt/v1.0.1/Release/native_rt-v1.0.1-electron-v19.0-darwin-x64.tar.gz
    node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (electron-v19.0 ABI, unknown) (falling back to source compile with node-gyp)
    node-pre-gyp http 403 status code downloading tarball https://nodeaddons.s3-us-west-2.amazonaws.com/native_rt/v1.0.1/Release/native_rt-v1.0.1-electron-v19.0-darwin-x64.tar.gz
    node-pre-gyp ERR! Tried to download(undefined): https://nodeaddons.s3-us-west-2.amazonaws.com/native_rt/v1.0.1/Release/native_rt-v1.0.1-electron-v19.0-darwin-x64.tar.gz
    node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (electron-v19.0 ABI, unknown) (falling back to source compile with node-gyp)
    node-pre-gyp http Connection closed while downloading tarball file
    gyp info it worked if it ends with ok
    gyp info using [email protected]
    gyp info using [email protected] | darwin | x64
    gyp info it worked if it ends with ok
    gyp info using [email protected]
    gyp info using [email protected] | darwin | x64
    gyp info ok
    gyp info ok
    gyp info it worked if it ends with ok
    gyp info using [email protected]
    gyp info using [email protected] | darwin | x64
    gyp info it worked if it ends with ok
    gyp info using [email protected]
    gyp info using [email protected] | darwin | x64
    gyp info find Python using Python version 3.7.5 found at "/path/to/user/.pyenv/versions/3.7.5/bin/python3"
    gyp info find Python using Python version 3.7.5 found at "/path/to/user/.pyenv/versions/3.7.5/bin/python3"
    gyp info spawn /path/to/user/.pyenv/versions/3.7.5/bin/python3
    gyp info spawn /path/to/user/.pyenv/versions/3.7.5/bin/python3
    gyp info spawn args [
    gyp info spawn args   '/path/to/project/node_modules/node-gyp/gyp/gyp_main.py',
    gyp info spawn args   'binding.gyp',
    gypgyp info  info spawn args [
    gyp info spawn args   '/path/to/project/node_modules/node-gyp/gyp/gyp_main.py',
    gyp info spawn args   'binding.gyp',
    gyp info spawn args   '-f',
    gyp info spawn args   'make',
    gyp info spawn args   '-I',
    gypspawn args info   '-f',
     spawn args   '/path/to/project/node_modules/native_rt/build/config.gypi',
    gypgyp info  infospawn args    'make',
    spawn argsgyp   '-I',
     gypinfo  infospawn args    '-I',
    spawn argsgyp   '/path/to/project/node_modules/node-gyp/addon.gypi',
    gyp  infoinfo  spawn argsspawn args   '-I',
    gyp   '/path/to/project/node_modules/native_rt/build/config.gypi',
     gypinfo  infospawn args    '/path/to/user/.electron-gyp/19.0.9/include/node/common.gypi',
    spawn argsgyp   '-I',
     gypinfo  infospawn args    '-Dlibrary=shared_library',
    spawn argsgyp   '/path/to/project/node_modules/node-gyp/addon.gypi',
    gyp  infoinfo  spawn argsspawn args   '-Dvisibility=default',
       '-I',
    gypgyp  infoinfo  spawn argsspawn args   '-Dnode_root_dir=/path/to/user/.electron-gyp/19.0.9',
       '/path/to/user/.electron-gyp/19.0.9/include/node/common.gypi',
    gypgyp  infoinfo  spawn argsspawn args   '-Dnode_gyp_dir=/path/to/project/node_modules/node-gyp',
    gyp   '-Dlibrary=shared_library',
     gypinfo  info spawn argsspawn args   '-Dnode_lib_file=/path/to/user/.electron-gyp/19.0.9/<(target_arch)/node.lib',
       '-Dvisibility=default',
    gypgyp  infoinfo  spawn argsspawn args   '-Dmodule_root_dir=/path/to/project/node_modules/native_rt',
       '-Dnode_root_dir=/path/to/user/.electron-gyp/19.0.9',
    gypgyp  infoinfo  spawn argsspawn args   '-Dnode_engine=v8',
       '-Dnode_gyp_dir=/path/to/project/node_modules/node-gyp',
    gypgyp  infoinfo  spawn argsspawn args   '--depth=.',
       '-Dnode_lib_file=/path/to/user/.electron-gyp/19.0.9/<(target_arch)/node.lib',
    gypgyp  infoinfo  spawn argsspawn args   '--no-parallel',
       '-Dmodule_root_dir=/path/to/project/node_modules/native_rt',
    gypgyp  infoinfo  spawn argsspawn args   '--generator-output',
       '-Dnode_engine=v8',
    gypgyp  infoinfo  spawn argsspawn args   'build',
       '--depth=.',
    gypgyp  infoinfo  spawn argsspawn args   '--no-parallel',
       '-Goutput_dir=.'
    gypgyp  infoinfo  spawn args   '--generator-output',
    spawn argsgyp ]
     info spawn args   'build',
    gyp info spawn args   '-Goutput_dir=.'
    gyp info spawn args ]
    gyp info ok
    gyp info ok
    gyp info it worked if it ends with ok
    gyp info using [email protected]
    gyp info using [email protected] | darwin | x64
    gyp info it worked if it ends with ok
    gyp info using [email protected]
    gyp info using [email protected] | darwin | x64
    gyp info spawn make
    gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
    gyp info spawn make
    gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
    rm: ./Release/.deps/Release/obj.target/native_rt/native-rt.o.d.raw: No such file or directory
    make: *** [Release/obj.target/native_rt/native-rt.o] Error 1
    gyp ERR! build error
    gyp ERR! stack Error: `make` failed with exit code: 2
    gyp ERR! stack     at ChildProcess.onExit (/path/to/project/node_modules/node-gyp/lib/build.js:194:23)
    gyp ERR! stack     at ChildProcess.emit (node:events:527:28)
    gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
    gyp ERR! System Darwin 21.4.0
    gyp ERR! command "/path/to/user/.nvm/versions/node/v16.16.0/bin/node" "/path/to/project/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/path/to/project/node_modules/native_rt/lib/binding/Release/electron-v19.0-darwin-x64/native_rt.node" "--module_name=native_rt" "--module_path=/path/to/project/node_modules/native_rt/lib/binding/Release/electron-v19.0-darwin-x64"
    gyp ERR! cwd /path/to/project/node_modules/native_rt
    gyp ERR! node -v v16.16.0
    gyp ERR! node-gyp -v v8.4.1
    gyp ERR! not ok
    node-pre-gyp ERR! build error
    node-pre-gyp ERR! stack Error: Failed to execute '/path/to/user/.nvm/versions/node/v16.16.0/bin/node /path/to/project/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/path/to/project/node_modules/native_rt/lib/binding/Release/electron-v19.0-darwin-x64/native_rt.node --module_name=native_rt --module_path=/path/to/project/node_modules/native_rt/lib/binding/Release/electron-v19.0-darwin-x64' (1)
    node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/path/to/project/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
    node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:527:28)
    node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1092:16)
    node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
    node-pre-gyp ERR! System Darwin 21.4.0
    node-pre-gyp ERR! command "/path/to/user/.nvm/versions/node/v16.16.0/bin/node" "/path/to/project/node_modules/native_rt/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
    node-pre-gyp ERR! cwd /path/to/project/node_modules/native_rt
    node-pre-gyp ERR! node -v v16.16.0
    node-pre-gyp ERR! node-pre-gyp -v v0.6.39
    node-pre-gyp ERR! not ok
error Command failed with exit code 1.
    gyp info ok

                    command=/path/to/user/.nvm/versions/node/v16.16.0/bin/node /path/to/user/.nvm/versions/node/v16.16.0/lib/node_modules/yarn/bin/yarn.js run install
                    workingDir=/path/to/project/node_modules/native_rt
  • exited          command=app-builder_amd64 code=2 pid=42417
ExecError: /path/to/project/node_modules/app-builder-bin/mac/app-builder_amd64 process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
Exit code:
2
    at ChildProcess.<anonymous> (/path/to/project/node_modules/builder-util/src/util.ts:250:14)
    at Object.onceWrapper (node:events:642:26)
    at ChildProcess.emit (node:events:527:28)
    at maybeClose (node:internal/child_process:1092:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5) {
  exitCode: 2,
  alreadyLogged: true,
  code: 'ERR_ELECTRON_BUILDER_CANNOT_EXECUTE'
}
@addlistener
Copy link
Author

addlistener commented Nov 9, 2022

After I upgraded the dep to
"@mapbox/node-pre-gyp": "^1.0.10",

The build is working.

However on windows the import failed. It says it's not a valid win32 application.

Error: \\?\C:\Users\vboxuser\AppData\Local\Temp\983798b8-6128-4c14-bddd-d3523c44209d.tmp.node is not a valid Win32 application.
\\?\C:\Users\vboxuser\AppData\Local\Temp\983798b8-6128-4c14-bddd-d3523c44209d.tmp.node
    at process.func [as dlopen] (node:electron/js2c/asar_bundle:5:1812)
    at Module._extensions..node (node:internal/modules/cjs/loader:1203:18)
    at Object.func [as .node] (node:electron/js2c/asar_bundle:5:2039)
    at Module.load (node:internal/modules/cjs/loader:988:32)
    at Module._load (node:internal/modules/cjs/loader:829:12)
    at c._load (node:electron/js2c/asar_bundle:5:13343)
    at Module.require (node:internal/modules/cjs/loader:1012:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (C:\Users\vboxuser\AppData\Local\Programs\MyApp\resources\app.asar\node_modules\native_rt\index.js:4:15)
    at Module._compile (node:internal/modules/cjs/loader:1118:14) {
  code: 'ERR_DLOPEN_FAILED'
}

Tested on a virtualbox win 10 and native win7. The error messages are the same.

My code is dead simple and it works on mac electron build.

import rt from 'native_rt';
console.log(rt.now());

And I can see that node-sqlite3 has a similar build process so it should work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant