• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

456
Vistas
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.

about 3 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

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.

about 3 years ago · Santiago Trujillo Denunciar

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?

about 3 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 Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda