Require in electron failed
snooze6 opened this issue · 3 comments
First of all stable electron (1.7.9) is based on nodeJS 7.9 so I'm using electron 1.8.1 beta which is based in node 8.2.1.
Steps to reproduce:
- Download some electron-quickstart (and make sure it works)
- Put this code at the end of the entry javascript file:
//TODO: Why this breaks?!
console.log(process.version);
try{
console.log('1');
const j = require('./frida/frida.js');
console.log(j);
} catch (e){
console.log('2');
console.log(e);
} finally {
console.log('3')
}
console.log('4');
- Enjoy the disappearance of the application and this output:
➜ src git:(ui) ✗ node_modules/.bin/electron main.js
v8.2.1
1
It imports fine in vanilla Node 8.2.1 without electron.
[Might be an electron issue]
Did you npm install the frida
module with these variables on the command-line: npm_config_runtime=electron npm_config_target=1.8.1
? You will also have to build frida-node for 1.8.x (see frida/releng/release.py for details) — you can use npm link
afterwards to use it in your Electron project.
I've tried to require frida in nw.js which uses 8.6.0 and it has the same problem.
After that I tried to compile it using npm:
export npm_config_runtime=electron
export npm_config_target=1.8.1
npm install frida
Which gives me an error importing <frida-core.h>:
prebuild-install WARN install No prebuilt binaries found (target=1.8.1 runtime=electron arch=x64 platform=darwin)
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
CXX(target) Release/obj.target/frida_binding/src/addon.o
In file included from ../src/addon.cc:1:
In file included from ../src/application.h:4:
In file included from ../src/glib_object.h:4:
In file included from ../src/runtime.h:4:
../src/glib_context.h:4:10: fatal error: 'frida-core.h' file not found
#include <frida-core.h>
^~~~~~~~~~~~~~
1 error generated.
make: *** [Release/obj.target/frida_binding/src/addon.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/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" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/**censored**/node_modules/frida
gyp ERR! node -v v8.7.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
Tomorrow I'll try to compile frida from source to check if it's possible to require it in something that isn't pure Node
Ok, It worked and immediately after that I realised that there is a frida-electron package which is exactly what I wanted in the releases page.
So I end up using electron 1.6.15 with the corresponding frida module. I simply created an .npmrc file and fill it with:
; userconfig /path/to/user/config/.npmrc
runtime = "electron"
target = "1.6.15"
My bad for not seeing the releases page.