node.js - Gatsby 默认启动器

标签 node.js reactjs windows gatsby

当我创建 gatsby-default-starter 网站时出现此错误。怎么解决呢。它有什么问题吗?

错误消息:

‼ pngquant pre-build test failed i compiling from source × Error: pngquant failed to build, make sure that libpng-dev is installed at D:\gatsby-project\my-gatsby-project\node_modules\bin-build\node_modules\execa\index.js:231:11 at runMicrotasks () at processTicksAndRejections (internal/process/task_queues.js:93:5) at async Promise.all (index 0) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="07617462716269737447362935293634" rel="noreferrer noopener nofollow">[email protected]</a> (node_modules\webpack-dev-server\node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7d1b0e180b1813090e3d4c534f534c4e" rel="noreferrer noopener nofollow">[email protected]</a>: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4523362033202b313605776b766b77" rel="noreferrer noopener nofollow">[email protected]</a> (node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1573667063707b616655273b263b27" rel="noreferrer noopener nofollow">[email protected]</a>: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b9c9d7dec8ccd8d7cd94dbd0d7f98f97899789" rel="noreferrer noopener nofollow">[email protected]</a> postinstall: node lib/install.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="cabaa4adbbbfaba4bee7a8a3a48afce4fae4fa" rel="noreferrer noopener nofollow">[email protected]</a> 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:

ERROR

Command failed with exit code 1: npm install

Error: Command failed with exit code 1: npm install

error.js:56 makeError [npm]/[gatsby-cli]/[execa]/lib/error.js:56:11

index.js:114 handlePromise [npm]/[gatsby-cli]/[execa]/index.js:114:26

task_queues.js:93 processTicksAndRejections internal/process/task_queues.js:93:5

init-starter.js:135 install [npm]/[gatsby-cli]/lib/init-starter.js:135:7

init-starter.js:202 clone [npm]/[gatsby-cli]/lib/init-starter.js:202:3

init-starter.js:343 initStarter [npm]/[gatsby-cli]/lib/init-starter.js:343:5

create-cli.js:494 [npm]/[gatsby-cli]/lib/create-cli.js:494:9

最佳答案

您似乎正在使用 Windows 作为操作系统。此问题通常与您可能需要的一些附加依赖项有关。请尝试以下操作:

  • 删除您的项目(以避免可能损坏的依赖项)。

  • 安装windows-build-tools作者:

    npm install --global windows-build-tools --vs2015
    
  • 运行您的入门命令并开发它。例如:

    npm install -g gatsby-cli
    
    gatsby new gatsby-site
    
    cd gatsby-site
    
    gatsby develop
    
  • 如果问题仍然存在,请尝试通过以下方式手动安装缺少的依赖项:

    npm install <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="11787c7076747c787f3c617f766064707f6551243f213f20" rel="noreferrer noopener nofollow">[email protected]</a> --save
    
    npm install <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5828363f292d39362c753a3136186b76697669" rel="noreferrer noopener nofollow">[email protected]</a> --save
    

更多详情请查看Gatsby on Windows docs .

关于node.js - Gatsby 默认启动器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67734980/

相关文章:

c# - 以编程方式选择用于 DirectX 渲染的最佳显卡

javascript - Node 模块和常规 javascript 文件有什么区别

reactjs - 使用 setTimeout 进行 Jest 测试 Hook 状态更新

windows - 在 C++ 中 Hook IDispatch v 表

javascript - 一页中的多个表单-reactjs

css - 在 Material UI 中使用 calc()

java - "Hello world"Android 应用,文件尽可能少,没有 IDE,只有文本编辑器

javascript - Body 解析器使用来自另一个中间件的 bodyParser 中间件

javascript - 我该如何修复 --> 文件是 CommonJS 模块;它可以转换为 ES6 模块

php - 如何与用户共享网络应用程序的实时源代码?