Netlify Gatsby build error, build works locally

Viewed 757

Yesterday and during many months everything worked fine when adding a blogpost via Contentful that triggered a build hook on Netlify. Today a new Blogg post add and build hook via Netlify does not work. When locally running gatsby develop or gatsby build everything works and the new blogpost is there.

Here is the error on Netlify: error "gatsby-node.js" threw an error while running the createPages lifecycle: 7:19:16 PM: Reducers may not dispatch actions:

enter image description here

  • Have tried "clearing cache and deploy site" button via Netlify
  • Have tried gatsby clean, npm install and pushing a triggered deploy also via GitHub

Unsure how to confirm cache is cleaned and what to try next. Any ideas?

Create pages:

const Promise = require('bluebird');
const path = require('path');

exports.createSchemaCustomization = ({ actions }) => {
  const { createTypes } = actions;
  const typeDefs = `
    type ContentfulHeroBanner implements Node {
      headerLeft: String
      headerCenter: String
      headerRight: String
    }
  `;
  createTypes(typeDefs);
};

exports.createPages = ({ graphql, actions }) => {
  const { createPage } = actions;

  return new Promise((resolve, reject) => {
    const blogPost = path.resolve('./src/templates/blog-post.js');
    resolve(
      graphql(
        `
          {
            allContentfulBlogPost {
              edges {
                node {
                  title
                  slug
                }
              }
            }
          }
        `
      ).then(result => {
        if (result.errors) {
          console.log(result.errors);
          reject(result.errors);
        }

        const posts = result.data.allContentfulBlogPost.edges;
        posts.forEach((post, index) => {
          createPage({
            path: `/blog/${post.node.slug}/`,
            component: blogPost,
            context: {
              slug: post.node.slug,
            },
          });
        });
      })
    );
  });
};
1 Answers

I managed to solve the problem. As I just tested removing the yarn.lock file without believing it would help. But after pushing this delete yarn.lock commit to master it triggered my build and this build Git repo without yarn.lock forced Netlify to rely on Installing NPM modules in the build and forgetting about Yarn.

This helped: https://community.netlify.com/t/support-guide-debugging-netlify-site-builds/142

Something mysterious regarding cache.

Related