node-ffi实践踩坑

  • Post author:
  • Post category:其他


单独运行nodejs调用user32.dll

在命令行工具窗口有焦点时,可以让目标程序获得焦点,反之不行

用electron 打包exe, 报错


was compiled against a different Node.js version using

NODE_MODULE_VERSION 57. This version of Node.js requires

NODE_MODULE_VERSION 64. Please try re-compiling or re-installing


Error: A dynamic link library (DLL) initialization routine failed.

网上方案一:删了重装

方案二:重编译

  1. npm i electron-rebuild -s

  2. ./node_modules/.bin/electron-rebuild  或

64位编译:

node-gyp rebuild –target=3.0.0 –arch=x64 –target_arch=x64 –dist-url=https://npm.taobao.org/mirrors/atom-shell

或一键编译:

electron-builder install-app-deps

一样报错,少了xxx.node文件,大多解决方案无 –abi参数,


Electron打包Node程序:怎么获取electron、node的abi以及指导abi获取版本(2) – 莫道 – 博客园

获取到对应的abi后(

NODE_MODULE_VERSION 64. Please try re-compiling or re-installing 也提示了iba版本

加入abi参数

(

electron node 版本不匹配的解决细节_真·skysys的博客-CSDN博客_electron node版本

)

npm rebuild –runtime=electron –target=3.0.0 –disturl=https://atom.io/download/atom-shell –abi=64

打包

electron-packager . HelloWorld –platform=win32 –arch=x64 –out=./out –asar –app-version=0.0.1 –electron-version 3.0.0

运行后还是一样,无焦点时,功能无法实现……………………..



版权声明:本文为qq_38239133原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。