Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

694
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!