Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

354
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda