I am trying to execute sudo command inside a bash script.
#!/bin/bash
sudo node app.js
and it throws me :
sudo: node: command not found
If I try to execute only node app.js (without sudo ),it runs ok.
If I try to just run sudo -h
, it prints the sudo help.
But , when I am trying the sudo node app.js
it throws me the error.
sudo $(which node) app.js
(which admittedly fails if there is nonode
in the user's path). – Ulrich Schwarz Jun 29 '16 at 14:50$(which node)
it works great!Thanks! – George Jun 29 '16 at 14:53