我尝试通过以下代码对我的电子项目使用bignum
包:
const { app, BrowserWindow, ipcMain } = require('electron');
const bignum = require('bignum');
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow;
const bignumValue = bignum("FFA122310DC", 16);
const createWindow = () => {
// Create the browser window.
mainWindow = new BrowserWindow({
globals:{
num: bignumValue.toString()
}
});
mainWindow.setMenu(null);
mainWindow.maximize();
// and load the index.html of the app.
mainWindow.loadURL(`file://${__dirname}/index.html`);
mainWindow.on('closed', () => {
mainWindow = null;
});
};
// 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);
app.on('before-quit', () => {
if (xmpp) {
xmpp.disconnect();
}
});
// Quit when all windows are closed.
app.on('window-all-closed', () => {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) {
createWindow();
}
});
process.on('unhandledRejection', (reason, p) => {
console.error('Possibly Unhandled Rejection at: Promise ', p, ' reason: ', reason);
});
process.on('SIGINT', () => {
if (xmpp) {
xmpp.disconnect();
}
process.exit(0);
});
但是上面的代码提供了以下错误:
> dummy_electron@1.0.0 start /home/pcmagas/Kwdikas/master_thesis/dummy_electron
> NODE_ENV=dev electron main.js
/home/pcmagas/Kwdikas/master_thesis/dummy_electron/node_modules/electron/dist/electron main.js: symbol lookup error: /home/pcmagas/Kwdikas/master_thesis/dummy_electron/node_modules/bignum/build/Release/bignum.node: undefined symbol: BN_new
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! dummy_electron@1.0.0 start: `NODE_ENV=dev electron main.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the dummy_electron@1.0.0 start 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! /home/pcmagas/.npm/_logs/2019-01-22T13_48_13_262Z-debug.log
由于某种原因,该库无法与openssl库连接。
库已这样安装:
npm install --save bignum
./node_modules/.bin/relectron-rebuild
我试图像这样重建它:
electron-rebuild --openssl-root="/usr/bin/openssl" --arch=x64
但是我仍然收到上面的错误。