Netlify Gatsby 构建错误,构建在本地工作
Netlify Gatsby build error, build works locally
昨天和许多个月里,通过 Contentful 添加博客时一切正常post,触发了 Netlify 上的构建挂钩。今天,新的 Blogg post 通过 Netlify 添加和构建挂钩不起作用。在本地 运行 gatsby develop 或 gatsby build 一切正常,新博客post 就在那里。
这是 Netlify 上的错误:错误“gatsby-node.js”在 运行 createPages 生命周期时引发错误:
7:19:16 PM:Reducers 可能不会调度操作:
- 已尝试通过 Netlify 的“清除缓存并部署站点”按钮
- 尝试过 gatsby clean、npm install 并通过 GitHub
推送触发部署
不确定如何确认缓存已清理以及接下来要尝试什么。有什么想法吗?
创建页面:
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,
},
});
});
})
);
});
};
我设法解决了问题。正如我刚刚测试删除 yarn.lock 文件而不相信它会有所帮助。但是在将这个 delete yarn.lock commit 推送到 master 之后,它触发了我的构建,这个没有 yarn.lock 的构建 Git repo 迫使 Netlify 在构建中依赖 Installing NPM modules
而忘记了 Yarn。
这有帮助:https://community.netlify.com/t/support-guide-debugging-netlify-site-builds/142
关于缓存的一些神秘的东西。
昨天和许多个月里,通过 Contentful 添加博客时一切正常post,触发了 Netlify 上的构建挂钩。今天,新的 Blogg post 通过 Netlify 添加和构建挂钩不起作用。在本地 运行 gatsby develop 或 gatsby build 一切正常,新博客post 就在那里。
这是 Netlify 上的错误:错误“gatsby-node.js”在 运行 createPages 生命周期时引发错误: 7:19:16 PM:Reducers 可能不会调度操作:
- 已尝试通过 Netlify 的“清除缓存并部署站点”按钮
- 尝试过 gatsby clean、npm install 并通过 GitHub 推送触发部署
不确定如何确认缓存已清理以及接下来要尝试什么。有什么想法吗?
创建页面:
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,
},
});
});
})
);
});
};
我设法解决了问题。正如我刚刚测试删除 yarn.lock 文件而不相信它会有所帮助。但是在将这个 delete yarn.lock commit 推送到 master 之后,它触发了我的构建,这个没有 yarn.lock 的构建 Git repo 迫使 Netlify 在构建中依赖 Installing NPM modules
而忘记了 Yarn。
这有帮助:https://community.netlify.com/t/support-guide-debugging-netlify-site-builds/142
关于缓存的一些神秘的东西。