Error: Could not locate the bindings file. Tried:

11,894

Solution 1

You need to rebuild the serialport module as it uses different V8 headers than Electron.

First you will need to set up a node-gyp toolchain (https://github.com/nodejs/node-gyp)

Next, install any version of Visual Studio.

Open a command window and change directory to node_modules/serialport within your project.

Enter this command with the appropriate variables:

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

For an example this is the command I use when rebuilding:

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

Solution 2

I had a problem that threw a Could not locate the bindings file error after merging package updates via Dependabot, and running npm audit fix.

My fix was running npm ci.

Solution 3

I had a similar problem. My solution: I got more specific about which version of nodejs I was using. I had the latest release (at this writing) 13.8 and I had the same problems as the OP.

So I installed nvm and started using it to pick my nodejs.

$ nvm install --lts 
$ nvm use --lts
Now using node v12.16.0

The current Long Term Support version (at this writing) is 12.6. I redid npm install for the app and after that I had no problems with the serial port. Theoretically, I could have kept nvm'installing different version of nodejs until I got the one that worked.

Share:
11,894

Related videos on Youtube

code_legend
Author by

code_legend

Updated on September 14, 2022

Comments

  • code_legend
    code_legend over 1 year

    I ran into the following error while trying to run my electron app that contains my express app.

    Error: Could not locate the bindings file. Tried:
    

    I think the issue has to do with serialport module, for without it being required everything works fine.

    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)