首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用带当然教程的gatsby源文件系统配置构建模式时出错

使用带当然教程的gatsby源文件系统配置构建模式时出错
EN

Stack Overflow用户
提问于 2022-08-12 08:43:56
回答 1查看 114关注 0票数 0

我对使用盖茨比( Gatsby )非常陌生,出于这个原因,我想通过遵循官方教程开始使用它。一切都进行得很顺利,直到我看到了第四部分:https://www.gatsbyjs.com/docs/tutorial/part-4/#task-use-graphiql-to-build-the-query-1

当我用gatsby-config.js配置更新我的gatsby-source-filesystem文件时,我无法在本地运行我的网站。

在我的终端中运行gatsby develop命令时,尝试构建模式时会出现以下错误:

代码语言:javascript
复制
gatsby develop    

success compile gatsby files - 1.288s 
success load gatsby config - 0.013s 
success load plugins - 0.303s 
success onPreInit - 0.004s 
success initialize cache - 0.074s 
success copy gatsby files - 0.049s 
success Compiling Gatsby Functions - 0.080s 
success onPreBootstrap - 0.087s 
success createSchemaCustomization - 0.002s 
success Checking for changed pages - 0.002s 
success source and transform nodes - 0.089s

 ERROR 

Missing onError handler for invocation 'building-schema', error was 'Error: TypeError[File.publicURL]: Cannot convert to OutputType the following value: Object({ type: String, args: Object({  }), description: "Copy file to static directory and return public url to it", resolve: [function resolve] })'. Stacktrace was 'Error: TypeError[File.publicURL]: Cannot convert to OutputType the following value: Object({ type: String, args: Object({  }), description: "Copy file to static directory and return public url to it", resolve: [function resolve] })
    at TypeMapper.convertOutputFieldConfig (/Users/nicolas/my-gatsby-site/node_m odules/graphql-compose/src/TypeMapper.ts:419:13)
    at ObjectTypeComposer.setField (/Users/nicolas/my-gatsby-site/node_modules/g raphql-compose/src/ObjectTypeComposer.ts:445:40)
    at /Users/nicolas/my-gatsby-site/node_modules/graphql-compose/src/ObjectType Composer.ts:479:14
    at Array.forEach (<anonymous>)
    at ObjectTypeComposer.addNestedFields (/Users/nicolas/my-gatsby-site/node_mo dules/graphql-compose/src/ObjectTypeComposer.ts:468:28)
    at forEach (/Users/nicolas/my-gatsby-site/node_modules/gatsby/src/schema/schema.js:764:39)
    at Array.forEach (<anonymous>)
    at /Users/nicolas/my-gatsby-site/node_modules/gatsby/src/schema/schema.js:764:18
    at async Promise.all (index 54)
    at updateSchemaComposer (/Users/nicolas/my-gatsby-site/node_modules/gatsby/src/schema/schema.js:168:3)
    at buildSchema (/Users/nicolas/my-gatsby-site/node_modules/gatsby/src/schema/schema.js:71:3)
    at build (/Users/nicolas/my-gatsby-site/node_modules/gatsby/src/schema/index.js:112:18)
    at buildSchema (/Users/nicolas/my-gatsby-site/node_modules/gatsby/src/servic es/build-schema.ts:19:3)'

⠸ building schema

然后building schema命令将永远运行,我的站点无法启动。

我知道问题是当将gatsby-source-filesystem添加到gatsby-config.js文件中时,因为当我删除它时,我可以运行gatsby develop而没有任何问题。

下面是我的gatsby-config.js文件,几乎与教程中的文件相同(我刚刚更改了博客标题):

代码语言:javascript
复制
module.exports = {
  siteMetadata: {
    title: `Arckablog`,
    siteUrl: `https://www.yourdomain.tld`,
  },
  plugins: [
    "gatsby-plugin-image",
    "gatsby-plugin-sharp",
    {
      resolve: "gatsby-source-filesystem",
      options: {
        name: `blog`,
        path: `${__dirname}/blog`,
      }
    },
  ],
}

我在这里看到了一个类似的关于堆栈溢出的问题:Error building schema with gatsby-source-filesystem config (following official tutorial)和我试着更新我的Gatsby版本和gatsby-source-filesystem版本,但是没有一个适合我。

你能给我个建议吗?

谢谢你的帮助!

尼古拉斯

EN

回答 1

Stack Overflow用户

发布于 2022-11-05 13:26:22

我也遇到了同样的问题。我从不同的文件夹运行npm install gatsby-source-filesystem。然后,我将当前文件夹更改为项目目录,并运行npm install gatsby-source-filesystem,一切正常。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73331503

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档