简体   繁体   中英

Node.js module cannot be required

I have written a Node.js server on the Raspberry pi, and have successfully previously used several modules in it.

However, in the most recent version, which requires the package serialport, I have received the following error message:

 /home/pi/hub/node_modules/serialport/node_modules/bindings/bindings.js:85
  throw err
        ^
Error: Could not load the bindings file. Tried:
 -> /home/pi/hub/node_modules/serialport/build/Debug/serialport.node
 -> /home/pi/hub/node_modules/serialport/build/Release/serialport.node
 -> /home/pi/hub/node_modules/serialport/out/Debug/serialport.node
 -> /home/pi/hub/node_modules/serialport/Debug/serialport.node
 -> /home/pi/hub/node_modules/serialport/out/Release/serialport.node
 -> /home/pi/hub/node_modules/serialport/Release/serialport.node
 -> /home/pi/hub/node_modules/serialport/build/default/serialport.node
 -> /home/pi/hub/node_modules/serialport/compiled/0.6/linux/arm/serialport.node
    at bindings (/home/pi/hub/node_modules/serialport/node_modules/bindings/bindings.js:82:13)
    at Object.<anonymous> (/home/pi/hub/node_modules/serialport/serialport.js:7:44)
    at Module._compile (module.js:446:26)
    at Object..js (module.js:464:10)
    at Module.load (module.js:353:32)
    at Function._load (module.js:311:12)
    at Module.require (module.js:359:17)
    at require (module.js:375:17)
    at Object.<anonymous> (/home/pi/hub/server.js:8:15)
    at Module._compile (module.js:446:26)

I have tried searching for this error, including on stackoverflow, but the few solutions that I found did not fix the problem.

UPDATE:

For reasons I cannot discern, I'm now getting a different error. I don't remember changing anything.

/home/pi/hub/node_modules/serialport/node_modules/bindings/bindings.js:77
        throw e
              ^
Error: Unable to load shared library     /home/pi/hub/node_modules/serialport/build/Release/serialport.node

I've doublechecked, and I'm pretty sure that serialport is installed in the right directory

Turns out that this will work if you install an earlier version of serialport:

npm install serialport@0.7.3

Guess the later versions weren't compatible with my version of nodejs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM