#StackBounty: #node.js #laravel #webpack #deployment #laravel-mix Can't run "npm run prod" using a deploy.sh file in a La…

Bounty: 200

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:


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->run(function ($type, $buffer) {

What I have tried already:

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

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.