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

122
Visualizações
Why is my React App not serving with PM2?

I am trying to run my React App with PM2 on an Ubuntu server. It has been running fine for years before today, and suddenly it stopped.

The one change I made today was that I reset my root password. But I can't think why that would make a difference.

I have created the app build.

If I just serve the app from the root directory of the application with serve -s build it serves correctly.

Then I try to serve the file using PM2 with a file 'ecosystem.config.js' that in my server root directory. This is the module:

  apps : [{
        name:'myapp',
        script: '../../var/www/myapp',
        interpreter : 'none',
        args: 'sudo serve -s build',
        watch: true,
        env: {
                NODE_ENV:'development',
        },
        env_production : {
                NODE_ENV: 'production'
        }
   }]
}

I run pm2 restart all and it seems to restart, but then it errors.

The log shows the following:

at WriteStream.emit (events.js:210:5)
at internal/fs/streams.js:299:10
at FSReqCallback.oncomplete (fs.js:146:23)
Error: Cannot find module '/var/www/myapp'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:794:15)
at Function.Module._load (internal/modules/cjs/loader.js:687:27)
at /usr/local/lib/node_modules/pm2/lib/ProcessContainer.js:297:23
at wrapper (/usr/local/lib/node_modules/pm2/node_modules/async/internal/once.js:12:16)
at next (/usr/local/lib/node_modules/pm2/node_modules/async/waterfall.js:96:20)
at /usr/local/lib/node_modules/pm2/node_modules/async/internal/onlyOnce.js:12:16
at WriteStream.<anonymous> (/usr/local/lib/node_modules/pm2/lib/Utility.js:186:13)
at WriteStream.emit (events.js:210:5)
at internal/fs/streams.js:299:10
at FSReqCallback.oncomplete (fs.js:146:23)```

Thank you for any ideas.
about 4 years ago · Juan Pablo Isaza
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