Closed adopudi closed 4 years ago
This issue is related to a recent change to the pigpio Node.js module. To help figure out what the problem is, can you please provide the following information:
What is the output of the following commands when run on the Raspberry Pi?
which pigpiod
which pigpiod | wc -l
And what is the output of the following commands when run on the Raspberry Pi?
cd /home/pi/dev/server/node_modules/pigpio
find .
Here is the output of those commands:
pi@rpi:~/dev/server $ which pigpiod
/usr/bin/pigpiod
pi@rpi:~/dev/server $ which pigpiod | wc -l
1
pi@rpi:~/dev/server $ cd /home/pi/dev/server/node_modules/pigpio
pi@rpi:~/dev/server/node_modules/pigpio $ find .
.
./README.md
./.travis.yml
./LICENSE
./build
./build/pigpio.target.mk
./build/config.gypi
./build/Makefile
./build/binding.Makefile
./build/Release
./build/Release/.deps
./build/Release/.deps/Release
./build/Release/.deps/Release/obj.target
./build/Release/.deps/Release/obj.target/pigpio
./build/Release/.deps/Release/obj.target/pigpio/src
./build/Release/.deps/Release/obj.target/pigpio/src/pigpio.o.d
./build/Release/.deps/Release/obj.target/pigpio.node.d
./build/Release/.deps/Release/pigpio.node.d
./build/Release/obj.target
./build/Release/obj.target/pigpio
./build/Release/obj.target/pigpio/src
./build/Release/obj.target/pigpio/src/pigpio.o
./build/Release/obj.target/pigpio.node
./build/Release/pigpio.node
./binding.gyp
./pigpio.d.ts
./package.json
./test
./test/wave-add.js
./test/pwm.js
./test/stress
./test/stress/notifier-leak-check.js
./test/stress/notifier-stress.js
./test/light-switch.js
./test/gpio-numbers.js
./test/pulse-led.js
./test/notifier-pwm.js
./test/isr-timeouts.js
./test/isr-performance.js
./test/alert-pwm-measurement.js
./test/alert-trigger-pulse-measurement.js
./test/gpio-mode.js
./test/hardware-revision.js
./test/pull-up-down.js
./test/do-nothing.js
./test/isr-enable-disable.js
./test/isr-timeouts-2.js
./test/waves.js
./test/tick.js
./test/isr-multiple-sources.js
./test/wave-chain.js
./test/blinky-pwm.js
./test/notifier.js
./test/digital-read-performance.js
./test/terminate.js
./test/servo-control.js
./test/digital-write-performance.js
./test/alert.js
./test/blinky.js
./test/gpio-glitch-filter.js
./test/run-tests
./test/trigger-led.js
./test/banked-leds.js
./pigpio.js
./History.md
./example
./example/light-switch.js
./example/pulse-led.js
./example/servo.png
./example/waveform.js
./example/button-debounce.js
./example/distance-hc-sr04.png
./example/wave-chain.js
./example/gpio-info.js
./example/distance-hc-sr04.js
./example/button-debounce.png
./example/alert.js
./example/blinky.js
./example/servo.js
./example/led-button.png
./src
./src/pigpio.cc
./doc
./doc/troubleshooting.md
./doc/gpiobank.md
./doc/gpio.md
./doc/global.md
./doc/notifier.md
Ok, that looks good.
What's the output of the following command:
sudo which pigpiod
pi@rpi:~/dev/server/node_modules/pigpio $ sudo which pigpiod
/usr/bin/pigpiod
Can you edit pigpio.js and replace these lines of code with this:
const pigpio = require('bindings')('pigpio.node');
Then try to run your test program again. I think an error will be thrown. Please post the complete exception stack trace.
pi@rpi:~/dev/server $ sudo node gpio-info
/home/pi/dev/server/node_modules/bindings/bindings.js:121
throw e;
^
Error: The module '/home/pi/dev/server/node_modules/pigpio/build/Release/pigpio.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 83. This version of Node.js requires
NODE_MODULE_VERSION 64. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
at Object.Module._extensions..node (internal/modules/cjs/loader.js:807:18)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at bindings (/home/pi/dev/server/node_modules/bindings/bindings.js:112:48)
at Object.<anonymous> (/home/pi/dev/server/node_modules/pigpio/pigpio.js:21:35)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
pi@rpi:~/dev/server $
We're getting there. Different major versions of Node.js were used at install time and run time. Perhaps this is because users root and pi have access to different versions of Node.js.
What's the output of the following commands:
node -v
sudo node -v
pi@rpi:~/dev/server $ node -v
v14.2.0
pi@rpi:~/dev/server $ sudo node -v
v10.20.1
This isn't a pigpio issue. The pi isn't set up correctly. You'll need to set it up so that users root and pi use the same version of Node.js.
Alternatively, you could use the following command to run your application:
sudo $(which node) gpio-info
This is the easiest option to fix it and it works great.
sudo $(which node) gpio-info
Thanks a lot for your help
In order to see the error shown in this comment the code in pigpio.js
had to be modified. The code had to be modified because it was swallowing the error and hiding it from the user. This isn't good and the error should be displayed.
Fixed by 8c958c115f1f3c7b1b4bf049714d0c2a9ae5c3da
OS: Raspbian 10.3 Node version: 14.2.0 Node module: gpio 3.2.1
I am trying to test the nodejs gpio module but got stuck with the following error:
From the error message it would seem the pigpio C library is not installed. But it's actually there:
... and
pigpiod
is not running.I have uninstalled and reinstalled both the C library and nodejs module several times without any benefit.
Any help is appreciated.