Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

training@4mation.com.au's avatar

npm install and npm run prod in deployment script failing.

I tried setup my laravel project in forge where whenever I deploy, it should run npm install and npm run prod.

But, the issue i am facing now which I have no idea why is that when I add npm install and npm run prod, it is complaining pngquant failed to build, make sure that libpng-dev is installed.


cd /home/forge/example.com

git pull origin master

npm install
npm run prod

composer install --no-interaction --prefer-dist --optimize-autoloader

echo "" | sudo -S service php7.2-fpm reload

if [ -f artisan ]
then
    php artisan migrate --force
fi

So, I go ahead and added sudo apt-get install -y libpng-dev, now I am facing another issue where it complains sudo: no tty present and no askpass program specified.


cd /home/forge/example.com

git pull origin master

sudo apt-get install -y libpng-dev
npm install
npm run prod

composer install --no-interaction --prefer-dist --optimize-autoloader

echo "" | sudo -S service php7.2-fpm reload

if [ -f artisan ]
then
    php artisan migrate --force
fi

Can anyone know what is going on or help me please?

0 likes
1 reply
Nash's avatar
Nash
Best Answer
Level 20

Just SSH into your server and install the package like you normally would.

You could also try with sudo -S or echo "" | sudo -S like in default script above, but I don't see why you would need to install a Linux package via your deployment script...it's not like you're going to have to install it every time you deploy.

Please or to participate in this conversation.