Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 7069

Run node script with specific user

$
0
0

On my laptop, Ubuntu 14.04, I create a file ~/test.js with the only content console.log("Hi, this is Dog."). I run the script node test.js (node v6.9.5), and I get the desired output Hi, this is Dog.

Then I try to run the script as www-data user. So I run:

sudo -u www-data /usr/bin/node /home/me/test.js

and...

Error: Cannot find module '/home/me/test.js'

What am I doing wrong?

I have tried with relative and absolute paths,

sudo -u www-data sh -c "/usr/bin/node /home/me/test.js"

changed the shell for www-data in /etc/passwd to /bin/bash and /bin/sh, and all the combinations of those ideas. Same error. Any idea?


Viewing all articles
Browse latest Browse all 7069

Trending Articles