Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

355
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda