Gatsby deploy to Netlify - error on createPages during building

Viewed 100

I'm having an error when I deploy my Gatsby portfolio to Netlify. On develop stage the gatsby-node.js create and display the created pages correctly but on building stage (netlify) it give an error:

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
1 Answers

Try moving your proyectos.js inside the src/templates folder in your page creation in the gatsby.node.js. Something like:

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

Tweak it to adapt it to your needs but change the path of the component.

Related