错误:找不到绑定文件。 尝试:

我试图运行包含我的快速应用程序的电子应用程序时,遇到以下错误。

Error: Could not locate the bindings file. Tried: 

我认为这个问题与serialport模块有关,因为没有它需要一切工作正常。

 C:\Users\Jonathan\Desktop\client\<NAME>\electron-with-express\express-app\node_modules\bindings\bindings.js:91 <br>Error: Could not locate the bindings file. Tried: <br> → C:\Users\Jonathan\Desktop\client\<NAME>\electron-with-express\express-app\node_modules\serialport\build\serialport.node <br> → C:\Users\Jonathan\Desktop\client\<NAME>\electron-with-express\express-app\node_modules\serialport\build\Debug\serialport.node <br> → C:\Users\Jonathan\Desktop\client\<NAME>\electron-with-express\express-app\node_modules\serialport\build\Release\serialport.node <br> → C:\Users\Jonathan\Desktop\client\<NAME>\electron-with-express\express-app\node_modules\serialport\out\Debug\serialport.node <br> → C:\Users\Jonathan\Desktop\client\<NAME>\electron-with-express\express-app\node_modules\serialport\Debug\serialport.node <br> → C:\Users\Jonathan\Desktop\client\<NAME>\electron-with-express\express-app\node_modules\serialport\out\Release\serialport.node <br> → C:\Users\Jonathan\Desktop\client\<NAME>\electron-with-express\express-app\node_modules\serialport\Release\serialport.node <br> → C:\Users\Jonathan\Desktop\client\<NAME>\electron-with-express\express-app\node_modules\serialport\build\default\serialport.node <br> → C:\Users\Jonathan\Desktop\client\<NAME>\electron-with-express\express-app\node_modules\serialport\compiled\6.3.1\win32\ia32\serialport.node <br> at bindings (C:\Users\Jonathan\Desktop\client\<NAME>\electron-with-express\express-app\node_modules\bindings\bindings.js:88:9) <br> at Object.<anonymous> (C:\Users\Jonathan\Desktop\client\<NAME>\electron-with-express\express-app\node_modules\serialport\lib\bindings.js:3:35) <br></anonymous> at Module._compile (module.js:541:32) <br> at Object.Module._extensions..js (module.js:550:10) <br> at Module.load (module.js:458:32) <br> at tryModuleLoad (module.js:417:12) <br> at Function.Module._load (module.js:409:3) <br> at Module.require (module.js:468:17) <br> at require (internal/module.js:20:19) <br> at Object.<anonymous> (C:\Users\Jonathan\Desktop\client\<NAME>\electron-with-express\express-app\node_modules\serialport\lib\serialport.js:15:25) 

您需要重build串口模块,因为它使用不同于Electron的V8头文件。

首先你需要build立一个node-gyp工具链( https://github.com/nodejs/node-gyp

接下来,安装任何版本的Visual Studio。

打开一个命令窗口,并在您的项目中将目录更改为node_modules / serialport。

用适当的variablesinput这个命令:

 node-gyp rebuild --target=<electron_version> --arch=<arch> --dist-url="https://atom.io/download/atom-shell" --msvs_version=<visual_studio_year> 

例如,这是我在重build时使用的命令:

 node-gyp rebuild --target=1.2.5 --arch=x64 --dist-url="https://atom.io/download/atom-shell" --msvs_version=2013