Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

351
Views
NodeJS on production server - permissions

I want to have node and npm available for whatever user is on the system.

In our team, when someone updates code from git they run:sudo -u www-data git pull

So whatever project it is, we always go through www-data user.

Now we have new Node project and need to do the same. There is no way that on our production server we will rely on one user handling everything about node - what if he leaves tomorrow?

So we are not using NVM, but installing Node as a root as described here

Its all fine, and all users see node and npm executable. Problems start when we actually try to use them.

What you want to do is:

cd /var/www/node_project
sudo -u www-data git pull
sudo -u www-data npm install

This fails on last command, because npm is trying to write lock file in my home directory. So:/home/user/.npm instead of somewhere globally or /var/www/.npm which would be home directory for www-data user.

Similar to that, after installing

sudo npm install -g typings

And then running sudo -u www-data typings install you get an error, because it is trying to write /home/user/.config/configstore/insight-typings.json

Could someone please elaborate how to actually properly install node on server? If I run sudo -u www-data how come npm ins still going into my home folder?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can specify directory for global installs from some user:

set prefix = ~/.where_to_install in ~/.npmrc

then add in PATH variable proper location for executables (like ~/.npm/bin)

Btw, what is home dir for www-data in your case?

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!