Closed ralflici closed 2 years ago
It's likely that the version of node used when you sudo is different to the one you get as a regular user.
You should be able to verify this by comparing the output of these two commands:
$ node --version
$ sudo node --version
In your case the node
run without sudo, and therefore the one used by npm install
, is newer than the second.
By default the $PATH
environment variable is not passed to the sudo environment. You can either fix this in sudoers by adding it to the list of variables that are passed through, or be specific about which node you want to run on the command line, e.g.:
$ sudo /path/to/newer/node ...
Hope that helps.
Yes you were right, the node version of sudo was outdated and different from the "regular" one. I just edited the sudoers file by prepending the path to the new version of node in the secure_path
variable. Now the script is running without problems.
Thank you very much!
This is the code I'm trying to run on the Raspberry Pi:
and the error I get from node when trying to run the script (with sudo):
I'v tried
npm rebuild
andnpm install
, I have also deleted manually the node_modules folder and reinstalled the rpio library but it did not solve my problem.Scripts that handle GPIO functions show no problems but now I'm interested in PWM so the the
gpiomem
falg must be set tofalse
in my case.Hardware: Raspberry PI 3 Model B+
Node: v14.15.4
NPM: v6.14.10