Gatsby 在克隆 git 存储库时开发失败

Gatsby fails at develop when cloning git repository

当我创建新项目并按照以下步骤操作时,我的 gatsby 项目运行完美:https://www.gatsbyjs.com/docs/quick-start/ 但是当我尝试克隆另一个存储库时,例如:

  1. git 克隆 https://repositoryurl
  2. npm 安装-g gatsby-cli
  3. npm 安装
  4. 盖茨比开发

它失败并出现错误 Failed at the pngquant-bin@5.0.2 postinstall script. 我尝试了不同的存储库,我在互联网上找到的所有解决方案都没有帮助。在你问 运行 npm install libpng-dev 之前给出 npm ERR! 404 Not Found - GET https://registry.npmjs.org/libpng-dev - Not found。 运行 npm install pngquant-bin 给出 npm ERR! pngquant-bin@6.0.0 postinstall node lib/install.js 我的节点版本:v12.18.3。我的 npm 版本:6.14.6。我用 Windows 10.

您需要安装 windows-build-tools。刚刚 运行:

npm install --global windows-build-tools --vs2015

许多 Gatsby 插件和主题需要构建原生 Node.js 模块,例如Sharp(一种用于图像处理的常见 Gatsby 依赖项,就像破坏代码的那个)。安装此软件包后,它会下载并安装 Microsoft 免费提供的 Visual C++ Build Tools 2015。这些工具是编译流行的本机模块所必需的。它还将安装 Python 2.7,配置您的机器,并适当地安装 npm。