Не получается запустить проект в режиме npm run dev - ERROR: Loading non-context-aware native module in renderer
Есть проект написанный на VUE + PHP. Писался для внешнего перефирийного устройства. При запуске на локалхост, все собирается, кроме Electron. Выдает ошибку:
Electron:
: '/home/ds/Antaros/redbutton/node_modules/serialport/node_modules/@serialport/bindings/build/Release/bindings.node'. This is deprecated, see https://github.com/electron/electron/issues/18397
Проект трехлетней давности. NODE V10, NPM V6.
Почитал англоязычный SOF, но нет решения, почитал отсылку на https://github.com/electron/electron/issues/18397 , но так и не понял, как обновить кондуль в контексте. Пробовал npm install @serialport/bindings@latest, но не привело к успеху. Обновить зависимости не могу т.к. придется весь код переписывать под новый синтаксис.
Добавлял app.allowRendererProcessReuse = false;(true) - не помогло
Подскажите плиз как настроить модуль electron ?
Прикладываю package.json для обзора и скрин с ошибками
{
"name": "redbutton",
"productName": "redbutton",
"version": "1.0.0",
"description": "RedButton",
"main": "./dist/main/main.js",
"scripts": {
"dev": "electron-webpack dev",
"compile": "electron-webpack",
"build": "npm run compile && electron-builder",
"lint": "eslint src --ext .js,.vue"
},
"keywords": [],
"author": "Vladimir Yazliev",
"license": "MIT",
"build": {
"npmRebuild": false,
"productName": "redbutton",
"directories": {
"output": "out/build"
},
"linux": {
"files": [
"!.gitignore",
"!.idea/*",
"!out/*",
"!src/*",
"!dist/*",
"!.redbutton/*",
"build/**",
"migrations/*"
],
"asar": true,
"icon": "build/icon.png",
"target": [
{
"target": "AppImage",
"arch": [
"armv7l",
"x64"
]
}
]
}
},
"electronWebpack": {
"title": "RedButton",
"renderer": {
"template": "src/index.html",
"webpackConfig": "webpack.render.config.js"
}
},
"browserslist": [
"> 1%",
"last 3 versions",
"ExplorerMobile >= 10",
"chrome 49",
"IE >= 10"
],
"dependencies": {
"bcrypt": "^4.0.1",
"datatables.net": "^1.10.20",
"drivelist": "^8.0.10",
"electron-download-manager": "^2.1.2",
"electron-log": "^4.0.7",
"electron-shutdown-command": "0.0.8",
"electron-simple-updater": "^2.0.8",
"email-validator": "^2.0.4",
"excel4node": "^1.7.2",
"executive": "^1.6.3",
"fs-extra": "^8.1.0",
"ip": "^1.1.5",
"jquery": "^3.4.1",
"loudness": "^0.3.0",
"moment": "^2.24.0",
"moment-duration-format": "^2.3.2",
"nodemailer": "^6.4.4",
"pi-wifi": "^1.2.0",
"serialport": "^8.0.7",
"slick-carousel": "^1.8.1",
"source-map-support": "^0.5.16",
"sqlite": "^3.0.3",
"ulid": "^2.3.0",
"vue": "^2.6.11",
"vue-i18n": "^8.15.4",
"vue-router": "^3.1.6",
"vue-touch": "^2.0.0-beta.4",
"vue-touch-keyboard": "^0.3.2",
"vuex": "^3.1.2"
},
"devDependencies": {
"autoprefixer": "^9.7.4",
"electron": "^8.0.3",
"electron-builder": "^22.3.2",
"electron-rebuild": "^1.10.0",
"electron-webpack": "^2.7.4",
"eslint": "^6.8.0",
"eslint-config-standard": "^14.1.0",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1",
"eslint-plugin-vue": "^6.1.2",
"node-abi": "^2.15.0",
"node-sass": "^4.13.1",
"postcss-loader": "^3.0.0",
"postinstall": "^0.7.0",
"sass-loader": "^8.0.2",
"vue-loader": "^15.9.0",
"vue-template-compiler": "^2.6.11",
"webpack": "^4.42.0"
}
}
"use strict";
import { app, BrowserWindow } from "electron";
import * as path from "path";
import { format as formatUrl } from "url";
const DownloadManager = require("electron-download-manager");
DownloadManager.register({
downloadFolder: process.env.PWD,
});
const isDevelopment = true;
// const isDevelopment = process.env.NODE_ENV !== 'production';
let mainWindow;
function createMainWindow() {
let windowOptions;
if (isDevelopment) {
windowOptions = {
width: 1280,
height: 800,
icon: path.join(__dirname, "build", "icon.png"),
title: "RedButton",
webPreferences: {
devTools: isDevelopment,
nodeIntegration: true,
},
};
} else {
windowOptions = {
icon: path.join(__dirname, "build", "icon.png"),
title: "RedButton",
alwaysOnTop: true,
frame: false,
autoHideMenuBar: true,
webPreferences: {
devTools: isDevelopment,
nodeIntegration: true,
},
};
}
const window = new BrowserWindow(windowOptions);
if (isDevelopment) {
window.webContents.openDevTools();
} else {
window.setFullScreen(true);
}
if (isDevelopment) {
window.loadURL(`http://localhost:${process.env.ELECTRON_WEBPACK_WDS_PORT}`);
} else {
window.loadURL(
formatUrl({
pathname: path.join(__dirname, "index.html"),
protocol: "file",
slashes: true,
})
);
}
window.on("closed", () => {
mainWindow = null;
});
window.webContents.on("devtools-opened", () => {
window.focus();
setImmediate(() => {
window.focus();
});
});
return window;
}
app.on("window-all-closed", () => {
if (process.platform !== "darwin") {
app.quit();
}
});
app.on("activate", () => {
if (mainWindow === null) {
mainWindow = createMainWindow();
}
});
app.on("ready", () => {
mainWindow = createMainWindow();
// app.allowRendererProcessReuse = false;
});