在主进程中require('robotjs')之后报错 NODE_MODULE_VERSION
查看了robotjs文档,意思大概是要rebuild一下, target是electron的版本,abi是node 的abi版本(该版本electron所对应的node版本,⚠️不是当前的node版本)。
通过process.version可以查看到版本相关信息。
console.log('process.version',process.version); // 该版本electron所对应的node版本
console.log('process.versions.electron', process.versions.electron); // electron 版本
console.log('process.versions.modules', process.versions.modules); // abi
然后执行
npm rebuild --runtime=electron --target=23.0.0 --disturl=https://atom.io/download/atom-shell --abi=123
发现报错 依旧是node版本的问题!!! 九敏
几经搜索 发现了另一个方法是生效的
// 先安装electron-rebuild
npm install electron-rebuild
// 然后
./node_modules/.bin/electron-rebuild
大功告成 可以愉快使用robot啦🎉🎉🎉