当我尝试在cPanel上安装Laravel时出现pngquant错误

时间:2019-05-08 14:54:25

标签: node.js laravel npm cpanel pngquant

我对cPanel的经验很少,但是需要在cpanel上安装Laravel应用程序。我真的在努力解决这个问题。

这是我正在采取的步骤:

  1. Git检出存储库
  2. 设置.env
  3. composer安装
  4. 撰写者更新
  5. chmod -R 775存储和chmod 775引导程序/缓存
  6. npm install -g npm凉亭纱
  7. 纱线安装
  8. 下装
  9. npm run dev
  10. php artisan migration:fresh --seed

(所有步骤的原因是因为我正在设置自己购买的主题,该主题在cPanel之外的所有地方都适用。)

我遇到的问题是当我尝试安装npm时。

运行npm install时出现以下错误:

> pngquant-bin@3.1.1 postinstall /public_html/src/node_modules/pngquant-bin
> node lib/install.js

  ⚠ The `/public_html/src/node_modules/pngquant-bin/vendor/pngquant` binary doesn't seem to work correctly
  ⚠ pngquant pre-build test failed
  ℹ compiling from source
  ✖ Error: pngquant failed to build, make sure that libpng-dev is installed
    at ChildProcess.exithandler (child_process.js:294:12)
    at ChildProcess.emit (events.js:189:13)
    at maybeClose (internal/child_process.js:970:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)

我尝试了各种资源:

https://github.com/imagemin/pngquant-bin/issues/78

https://github.com/papandreou/node-pngquant/issues/14

我可以告诉您已安装pngquant(直接从git和npm中尝试安装)仍然是相同的错误。

libpng-dev已安装(我认为):

identify -list format | grep PNG

  JNG* PNG       rw-   JPEG Network Graphics
  MNG* PNG       rw+   Multiple-image Network Graphics (libpng 1.2.46,1.2.49)
  PNG* PNG       rw-   Portable Network Graphics (libpng 1.2.46,1.2.49)
       See http://www.libpng.org/ for details about the PNG format.
PNG24* PNG       rw-   opaque 24-bit RGB (zlib 1.2.3)
PNG32* PNG       rw-   opaque or transparent 32-bit RGBA
 PNG8* PNG       rw-   8-bit indexed with optional binary transparency

我已经尝试过了:

npm install imagemin-pngquant@5.0.1 --save
npm install pngquant-bin@3.1.1

仍然出现相同的错误

[~/public_html/src]# npm install pngquant-bin@3.1.1 --save

> pngquant-bin@3.1.1 postinstall /public_html/src/node_modules/pngquant-bin
> node lib/install.js

  ⚠ The `/public_html/src/node_modules/pngquant-bin/vendor/pngquant` binary doesn't seem to work correctly
  ⚠ pngquant pre-build test failed
  ℹ compiling from source
  ✖ Error: pngquant failed to build, make sure that libpng-dev is installed
    at ChildProcess.exithandler (child_process.js:294:12)
    at ChildProcess.emit (events.js:189:13)
    at maybeClose (internal/child_process.js:970:16)
    at Socket.stream.socket.on (internal/child_process.js:389:11)
    at Socket.emit (events.js:189:13)
    at Pipe._handle.close (net.js:597:12)

我还尝试将其添加到package.json

"resolutions": {
    "image-webpack-loader/imagemin-pngquant": "5.0.1"
  }

我的节点和npm版本是:

node -v v10.15.3

npm -v 6.9.0

最后,这是我的bin文件夹的样子:

[~/bin]# ls
./   bower@  node_modules/  npm-cli.js@  pngquant@  yarn.lock
../  node*   npm@           npx@         yarn@      yarnpkg@

对我来说,似乎pngquant已正确安装,但由于某种原因找不到libpng-dev?有什么想法吗?救命?!请帮忙。

1 个答案:

答案 0 :(得分:0)

首先请确保您确实拥有libpng-dev而不仅仅是libpng

dpkg -l libpng-dev

如果未返回任何东西,则说明您没有安装它,因此您还需要Essentials软件包,因此请确保您还拥有该软件包:

sudo apt install build-essential libpng-dev

完成此操作后,您很可能需要删除node_modules文件夹

rm -rf node_modules

然后再次运行npm install