Gatsby 部署到 Netlify - 构建过程中 createPages 出错

Gatsby deploy to Netlify - error on createPages during building

我在将我的 Gatsby 产品组合部署到 Netlify 时遇到错误。 在开发阶段,gatsby-node.js 创建并正确显示创建的页面,但在构建阶段 (netlify) 出现错误:

9:54:19 PM: success loading DatoCMS schema - 0.765s
9:54:19 PM: success createSchemaCustomization - 0.857s
9:54:22 PM: success loading DatoCMS content - 2.933s
9:54:22 PM: success Checking for changed pages - 0.000s
9:54:22 PM: success source and transform nodes - 3.285s
9:54:22 PM: info Writing GraphQL type definitions to /opt/build/repo/.cache/schema.gql
9:54:24 PM: success building schema - 1.413s
9:54:24 PM: [
9:54:24 PM:   [Object: null prototype] { slug: 'pro2' },
9:54:24 PM:   [Object: null prototype] { slug: 'pro3' },
9:54:24 PM:   [Object: null prototype] { slug: 'pro1' }
9:54:24 PM: ]
9:54:24 PM: error "gatsby-node.js" threw an error while running the createPages lifecycle:
9:54:24 PM: Cannot find module './src/components/proyectos.js'
9:54:24 PM: Require stack:
9:54:24 PM: - /opt/build/repo/gatsby-node.js

尝试将 proyectos.js 移动到 src/templates 文件夹中,然后在 gatsby.node.js 中创建页面。类似于:

createPage({
  path: `/proyectos/${node.id}`,,
  component: path.resolve(`src/templates/proyectos.js`),
  context: {
    pagePath: path,
  },
})

调整它以适应您的需要,但更改 component 的路径。