// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow);
//async function main() {
app.whenReady()
.then(() => {
// The event listener
ipcMain.handle('setDefaults', handleDefaults);
})
`
D) When I try to run it (after uncommenting the main() stuff in ping.js it fails like this:
lutzbickhardt_27@Lutzs-iMac etestping % npm start
my-app@1.0.0 start
electron-forge start
✔ Checking your system
✔ Locating application
✔ Loading configuration
✖ Preparing native dependencies: 0 / 1
› node-gyp failed to rebuild '/Users/lutzbickhardt_27/etestping/node_modules/raw-socket'
◼ Running generateAssets hook
› CXX(target) Release/obj.target/raw/src/raw.o
In file included from ../src/raw.cc:6:
In file included from ../src/raw.h:23:
In file included from ../../nan/nan.h:176:
../../nan/nan_callbacks.h:55:23: error: no member named 'AccessorSignature' in namespace 'v8'
typedef v8::Local Sig;
In file included from ../src/raw.cc:6:
In file included from ../src/raw.h:23:
../../nan/nan.h:682:39: warning: 'IdleNotificationDeadline' is deprecated: Use MemoryPressureNotification() to influence the GC schedule. [-Wdeprecated-declarations]
return v8::Isolate::GetCurrent()->IdleNotificationDeadline(
^
/Users/lutzbickhardt_27/.electron-gyp/29.1.5/include/node/v8-isolate.h:1378:3: note: 'IdleNotificationDeadline' has been explicitly marked deprecated here
V8_DEPRECATE_SOON(
^
/Users/lutzbickhardt_27/.electron-gyp/29.1.5/include/node/v8config.h:569:39: note: expanded from macro 'V8_DEPRECATE_SOON'
# define V8_DEPRECATE_SOON(message) [[deprecated(message)]]
^
In file included from ../src/raw.cc:6:
In file included from ../src/raw.h:23:
../../nan/nan.h:2542:8: error: no matching member function for call to 'SetAccessor'
tpl->SetAccessor(
~~~~~^~~~~~~~~~~
/Users/lutzbickhardt_27/.electron-gyp/29.1.5/include/node/v8-template.h:806:8: note: candidate function not viable: no known conversion from 'v8::AccessControl' to 'v8::…
void SetAccessor(
^
/Users/lutzbickhardt_27/.electron-gyp/29.1.5/include/node/v8-template.h:800:8: note: candidate function not viable: no known conversion from 'imp::NativeGetter' (aka 'vo…
void SetAccessor(
^
In file included from ../src/raw.cc:6:
In file included from ../src/raw.h:23:
../../nan/nan.h:2586:15: warning: 'SetAccessor' is deprecated: Use SetNativeDataProperty instead [-Wdeprecated-declarations]
return obj->SetAccessor(
^
/Users/lutzbickhardt_27/.electron-gyp/29.1.5/include/node/v8-object.h:344:3: note: 'SetAccessor' has been explicitly marked deprecated here
V8_DEPRECATE_SOON("Use SetNativeDataProperty instead")
^
/Users/lutzbickhardt_27/.electron-gyp/29.1.5/include/node/v8config.h:569:39: note: expanded from macro 'V8_DEPRECATE_SOON'
# define V8_DEPRECATE_SOON(message) [[deprecated(message)]]
^
In file included from ../src/raw.cc:6:
In file included from ../src/raw.h:21:
In file included from /Users/lutzbickhardt_27/.electron-gyp/29.1.5/include/node/node.h:79:
In file included from /Users/lutzbickhardt_27/.electron-gyp/29.1.5/include/node/v8.h:24:
In file included from /Users/lutzbickhardt_27/.electron-gyp/29.1.5/include/node/v8-array-buffer.h:12:
/Users/lutzbickhardt_27/.electron-gyp/29.1.5/include/node/v8-local-handle.h:268:5: error: static_assert failed due to requirement 'std::is_base_of<v8::Value, v8::Data>::…
static_assert(std::is_base_of<T, S>::value, "type check");
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../nan/nan_callbacks_12_inl.h:175:20: note: in instantiation of function template specialization 'v8::Local<v8::Value>::Local<v8::Data>' requested here
cbinfo(info, obj->GetInternalField(kDataIndex));
^
2 warnings and 3 errors generated.
make: *** [Release/obj.target/raw/src/raw.o] Error 1
Error: `make` failed with exit code: 2
at ChildProcess.onExit (/Users/lutzbickhardt_27/etestping/node_modules/node-gyp/lib/build.js:203:23)
at ChildProcess.emit (node:events:513:28)
at Process.ChildProcess._handle.onexit (node:internal/child_process:293:12)
An unhandled rejection has occurred inside Forge:
Error: node-gyp failed to rebuild '/Users/lutzbickhardt_27/etestping/node_modules/raw-socket'
at ChildProcess.<anonymous> (/Users/lutzbickhardt_27/etestping/node_modules/@electron/rebuild/lib/module-type/node-gyp/node-gyp.js:118:24)
at ChildProcess.emit (node:events:513:28)
at Process.ChildProcess._handle.onexit (node:internal/child_process:293:12)
E) Restarting just the standalone ping.js result in this:
node:internal/modules/cjs/loader:988
throw err;
^
Error: Cannot find module './build/Release/raw.node'
Require stack:
- /Users/lutzbickhardt_27/etestping/node_modules/raw-socket/index.js
- /Users/lutzbickhardt_27/etestping/node_modules/net-ping/index.js
- /Users/lutzbickhardt_27/etestping/src/ping.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:985:15)
at Function.Module._load (node:internal/modules/cjs/loader:833:27)
at Module.require (node:internal/modules/cjs/loader:1057:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.<anonymous> (/Users/lutzbickhardt_27/etestping/node_modules/raw-socket/index.js:4:11)
at Module._compile (node:internal/modules/cjs/loader:1155:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
at Module.load (node:internal/modules/cjs/loader:1033:32)
at Function.Module._load (node:internal/modules/cjs/loader:868:12)
at Module.require (node:internal/modules/cjs/loader:1057:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Users/lutzbickhardt_27/etestping/node_modules/raw-socket/index.js',
'/Users/lutzbickhardt_27/etestping/node_modules/net-ping/index.js',
'/Users/lutzbickhardt_27/etestping/src/ping.js'
]
}
F) then I havee to do a npm clean-install and then it works ok again.
G) it seems the electron forge installation rsults in a corrupted raw-socket installation. But why? I have no idea! Can you help?
A) I have converted ping to use async instead of a callback:
`const ping = require ("net-ping");
async function pingTV(ip) { let dbg= true console.log ("[main]", "ping ip = " + ip); var session = ping.createSession (); return await new Promise(resolve => { session.pingHost (ip, function (error, target) { if (error) { console.log (error) resolve(error.toString()) } else { console.log (target + ": Alive"); resolve("Alive") } }); }); }
async function main() { const ip= "192.168.1.112" let tvalive= "bullshit" tvalive= await pingTV(ip) console.log ("[main]", "tvalive", tvalive); }
main()
//exports.pingTV= pingTV();`
B) and it works fine:
lutzbickhardt_27@Lutzs-iMac etestping % node src/ping.js [main] ping ip = 192.168.1.111 192.168.1.111: Alive [main] tvalive Alive lutzbickhardt_27@Lutzs-iMac etestping % node src/ping.js [main] ping ip = 192.168.1.112 [RequestTimedOutError: Request timed out] [main] tvalive RequestTimedOutError: Request timed out
C) Now I try to run it in a minimal electron environment (more or less like the get started with webpack option):
`const { app, BrowserWindow} = require('electron');
const pingTV = require ("./ping.js");
let TV_ALIVE; const vieraIP= '192.168.1.111'
// Handle creating/removing shortcuts on Windows when installing/uninstalling. if (require('electron-squirrel-startup')) { app.quit(); }
//let mainWindow; const createWindow = () => { // Create the browser window. let mainWindow = new BrowserWindow({ width: 800, height: 600, webPreferences: { preload: MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY, nodeIntegration: true, nativeWindowOpen: true } });
};
async function handleDefaults(event) { let dbg= true;
//SETUP= readSetup() //await pingTV(SETUP.vieraIP); }
// This method will be called when Electron has finished // initialization and is ready to create browser windows. // Some APIs can only be used after this event occurs. app.on('ready', createWindow);
//async function main() { app.whenReady() .then(() => { // The event listener ipcMain.handle('setDefaults', handleDefaults); }) ` D) When I try to run it (after uncommenting the main() stuff in ping.js it fails like this: lutzbickhardt_27@Lutzs-iMac etestping % npm start
✔ Checking your system ✔ Locating application ✔ Loading configuration ✖ Preparing native dependencies: 0 / 1 › node-gyp failed to rebuild '/Users/lutzbickhardt_27/etestping/node_modules/raw-socket' ◼ Running generateAssets hook
› CXX(target) Release/obj.target/raw/src/raw.o In file included from ../src/raw.cc:6: In file included from ../src/raw.h:23: In file included from ../../nan/nan.h:176: ../../nan/nan_callbacks.h:55:23: error: no member named 'AccessorSignature' in namespace 'v8' typedef v8::Local Sig;