Question

Node js as root and sudo user

Posted July 18, 2013 15.7k views
I installed the node.js as root user yesterday things are fine out there if I login as root user (Ubuntu 13.04 64 bit). As you know we don't wanna mess up with root user so created a sudo user and tried node command and found that it doesn't work for the new user. Is it normal or am I doing something wrong?? PS : Now I'm reinstalling nodejs for the sudo userr

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
3 answers
I think when you install node it places the node modules folder in the current users main directory. This means that if you created another user that cannot see inside the root folder node stops working correctly.

Most people advise against installing elements that don't require root- as root. Therefore, you'll probably be better off creating a normal simple user with a main directory as something like /home/. Then from there install NodeJs as that new simple user.
NodeJS is installed locally by default. You can run the installer as root and have it installed globally so all users can run it.
Hi - a recent article has some good info on how to run Node. Give it it a read - you may find it useful: https://www.digitalocean.com/community/articles/how-to-use-pm2-to-setup-a-node-js-production-environment-on-an-ubuntu-vps
by Jim Cassidy
Use these instructions to setup an Ubuntu server to run Node.js applications, including apps based on Express, Geddy, or Sails. This will help you avoid some security mistakes and will provide some surprising benefits.
Submit an Answer