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

696
Visualizações
Can't run "npm run prod" using a deploy.sh file in a Laravel project (using Laravel Mix)

I can run "npm run prod". I put the same command in a deploy.sh file. Again, I can still run the deploy script using ./deploy.sh, and it works. But the same deploy script could not run when the git hook happens.

"npm i" works both in the terminal, deploy script, and using git hook.

deploy.sh script is as follows:

#!/bin/sh

php artisan down
git pull origin $1
composer install --no-interaction --prefer-dist --optimize-autoloader --no-dev
php artisan migrate --force
php artisan cache:clear
php artisan route:cache
php artisan config:cache
npm ci

# everything works fine, but the line below
npm run production

php artisan up

And the weird thing is, in the terminal, when I run ./deploy.sh everything works, without any problem. but when the deploy script gets called using a GitHub webhook, it throws these errors:

terminal log

log file

So, npm run prod works in terminal, works when I run the deploy script by ./deploy.sh in the terminal, but not working when the git hook calls the laravel app to run the deploy script.

This is how I run the deploy.sh file using laravel:

$process = new Process(['./deploy.sh']);

$process->setWorkingDirectory(base_path());

$process->run(function ($type, $buffer) {
    Log::info($buffer);
});

What I have tried already:

using cross-env: not working. using rm -rf node_modules & npm cache clean --force & npm i: not working.

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

your code is not reproducible on my end. however my hypothesis is the laravels' log:info $buffer's stdout is clashing with master process' logging stdout. disable logging or change logging level and try the above procedure. it should work.

over 4 years ago · Santiago Trujillo Relatório

0

Are you running the correct command? You talk about running npm run prod locally but in your deploy.sh file it's npm run production?

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