节点版本:v12.22.11
电子版:^11.1.0版本
RobotJS版本:^0.6.0版本
执行项目时将提示以下错误消息。
App threw an error during load
Error: The module '\\?\\node_modules\robotjs\build\Release\robotjs.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 72. This version of Node.js requires
NODE_MODULE_VERSION 85. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
at process.func [as dlopen] (electron/js2c/asar_bundle.js:5:1812)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1203:18)
at Object.func [as .node] (electron/js2c/asar_bundle.js:5:1812)
at Module.load (internal/modules/cjs/loader.js:992:32)
at Module._load (internal/modules/cjs/loader.js:885:14)
at Function.f._load (electron/js2c/asar_bundle.js:5:12738)
at Module.require (internal/modules/cjs/loader.js:1032:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (\node_modules\robotjs\index.js:1:15)
at Module._compile (internal/modules/cjs/loader.js:1152:30)
我试过执行npm rebuild
和npm install
,但这并不能解决我的问题。
20221029-已更新
这是我的全部。json
{
"name": "robotjs-proj",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"postinstall": "electron-builder install-app-deps && node_modules/.bin/electron-rebuild --module-dir .",
"start": "electron ."
},
"author": "",
"license": "ISC",
"dependencies": {
"electron": "^11.1.0",
"electron-builder": "^23.6.0",
"mathjs": "^8.1.0",
"robotjs": "^0.6.0",
"robotjs-node12": "^0.5.3"
},
"devDependencies": {
"@types/node": "^18.11.7",
"electron-rebuild": "^2.3.4"
}
}
1条答案
按热度按时间yizd12fk1#
将postinstall脚本插入到package.json中