【问题标题】:When I'm trying to build a new project with gatsby-cli, I'm getting error当我尝试使用 gatsby-cli 构建新项目时,出现错误
【发布时间】:2020-08-17 17:13:33
【问题描述】:
‼ Command failed: C:\projects\my-blazing-fast-site\node_modules\pngquant-bin\vendor\pngquant.exe --version

‼ pngquant pre-build test failed
i compiling from source
× Error: pngquant failed to build, make sure that libpng-dev is installed
at Promise.all.then.arr (C:\projects\my-blazing-fast-site\node_modules\execa\index.js:231:11)
at processTicksAndRejections (internal/process/task_queues.js:86:5)
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! pngquant-bin@5.0.2 postinstall: node lib/install.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the pngquant-bin@5.0.2 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Maciek\AppDa

【问题讨论】:

    标签: reactjs npm npm-install gatsby


    【解决方案1】:

    为了获得解决方案,我按照以下步骤操作,

    1. 删除旧节点模块文件夹, 在安装之前先创建新的 Gatsby 项目,

      npm install --global windows-build-tools
      
    2. 然后,按照盖茨比文档创建项目,访问https://www.gatsbyjs.org/docs/quick-start/

      npm install -g gatsby-cli
      
      gatsby new gatsby-site
      
      cd gatsby-site
      
      gatsby develop
      
    3. 如果出现上述错误,我们需要外部安装

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

    【讨论】:

      【解决方案2】:

      我尝试了各种解决方案,在安装依赖 pngquant 的Sharp插件时遇到了这个问题。一种可能的方法是从 node_modules 中删除尖锐文件夹(或任何其他给你警告的插件)。然后插入以下代码。

      npm config set ignore-scripts false
      

      重新安装sharp/任何麻烦的插件,希望你能运行gatsby development。到目前为止,在我的机器上一切正常。

      【讨论】:

        猜你喜欢
        • 2020-06-16
        • 1970-01-01
        • 1970-01-01
        • 2021-02-13
        • 1970-01-01
        • 2020-04-16
        • 1970-01-01
        • 2023-03-08
        相关资源
        最近更新 更多