Reputation: 3808
I am making an application with electron which uses the wiring-pi library. This needs access to the GPIO on my Raspberry Pi, which requires root.
When I run electron .
in the folder, the app opens fine but then says (in the terminal):
wiringPiSetup: Must be root. (Did you forget sudo?)
However when I try sudo electron .
, I get an error:
sudo: electron: command not found
Does anyone know why this is happening? Also, for the record, the same thing happens when I run npm as root:
pi@raspberrypi:~/rubiks-robot $ sudo npm
sudo: npm: command not found
Any ideas of how I can fix this issue and run Electron as root?
Upvotes: 1
Views: 1609
Reputation: 3577
it looks like a problem of environment variables. The environmnet variables are set for your user but not for root.
Try to ship your variables with the "-E" switch of the sudo command:
sudo -E command
Please try to see here for other similar questions
How to keep Environment Variables when Using SUDO
Upvotes: 2