Once I finished in my local(Windows) everything is working as expected, but when I try to do npm install in the server with non-root user it's throwing this error.
Error: pngquant failed to build, make sure that libpng-dev is installed
at Promise.all.then.arr (/home/***/node_modules/pngquant-bin/node_modules/bin-build/node_modules/execa/index.js:231:11)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:118:7)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node lib/install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
If I run the same with root user it works.
Anyone knows the issue.?
libpng-dev is already installed in server, I tried lot of solution and none helps.
this is a problem with the dependencies of a dependency. pngquant needs pngquant-bin and npm detects it is not present (problem #1) and tries to build it, but fails (problem #2)
to fix problem #1 you could install the binary rpm - as the npm error suggest. But strangely the centos package is named libpng-devel not libpng-dev (as it is on debian (apt) based systems). I found I could get it installed like so:
problem #2 is a bigger issue. I dont want build tools on my prod server. Something changed for centos based laravel systems (recently, in 5.6) and after too many hours chasing why npm install on a stock 5.6 install fails I gave up and installed gcc/make/glibc-headers etc
I have managed to get this working on centos7 running WHM/Cpanel.
Firstly I had to ssh to the server as 'root'.
As the root user I navigated to my laravel folder and did a normal 'npm-install'
I then had to install my node packages with a 'npm install react-router-dom etc..'
Then I ssh as the user account, navigated to my laravel directory and
'npm run watch' works perfectly.
Any extra node packages would again need to be installed as root also else they have a permissions issue.