Node.js 盖茨比开发和盖茨比信息都返回错误
我不太清楚我的构建发生了什么,目前gatsby develop正在返回TypeError:无法读取指向此文件的未定义属性“allMarkdownRemark”Node.js 盖茨比开发和盖茨比信息都返回错误,node.js,gatsby,Node.js,Gatsby,我不太清楚我的构建发生了什么,目前gatsby develop正在返回TypeError:无法读取指向此文件的未定义属性“allMarkdownRemark” gatsby-node.js:19 graphql.then.results C:/Users/Anders/sites/gatsby-netlify-cms/gatsby-node.js:19:20 盖茨比信息在返回有关项目错误的信息后返回,系统无法找到指定的路径 下面是gatsby-node.js文件 我不太明白发生了什么,我回到了
gatsby-node.js:19 graphql.then.results
C:/Users/Anders/sites/gatsby-netlify-cms/gatsby-node.js:19:20
盖茨比信息在返回有关项目错误的信息后返回,系统无法找到指定的路径
下面是gatsby-node.js文件
我不太明白发生了什么,我回到了一分钟前运行良好的更改,现在出现了这个奇怪的错误。我尝试升级节点,尝试重新安装gatsby cli。我被卡住了。提前谢谢
还包括my package.json,以防不兼容
{
"name": "gatsby-starter-default",
"description": "Gatsby default starter",
"version": "1.0.0",
"author": "Kyle Mathews <mathews.kyle@gmail.com>",
"dependencies": {
"babel-plugin-styled-components": "^1.9.2",
"gatsby": "^2.0.53",
"gatsby-image": "^2.0.22",
"gatsby-plugin-manifest": "^2.0.9",
"gatsby-plugin-netlify": "^2.0.6",
"gatsby-plugin-netlify-cms": "^3.0.9",
"gatsby-plugin-offline": "^2.0.16",
"gatsby-plugin-react-helmet": "^3.0.2",
"gatsby-plugin-sharp": "^2.0.15",
"gatsby-plugin-sitemap": "^2.0.3",
"gatsby-plugin-styled-components": "^3.0.4",
"gatsby-source-filesystem": "^2.0.10",
"gatsby-transformer-remark": "^2.1.15",
"gatsby-transformer-sharp": "^2.1.9",
"netlify-cms": "^2.3.0",
"react": "^16.6.3",
"react-dom": "^16.6.3",
"react-helmet": "^5.2.0",
"react-spring": "^6.1.10",
"styled-components": "^4.1.2"
},
"keywords": [
"gatsby"
],
"license": "MIT",
"scripts": {
"build": "gatsby build",
"develop": "gatsby develop",
"start": "npm run develop",
"format": "prettier --write \"src/**/*.js\"",
"test": "echo \"Error: no test specified\" && exit 1"
},
"devDependencies": {
"prettier": "^1.15.2"
},
"repository": {
"type": "git",
"url": "https://github.com/gatsbyjs/gatsby-starter-default"
}
}
我在盖茨比源文件系统src/team/riles first post.md中有一个文件,您还没有发布您的盖茨比配置文件,但从错误判断,我认为您的节点文件找不到任何标记文件,导致未定义的results.data 在gatsby配置文件中,应该有一个类似于以下指令的指令:
{
resolve: `gatsby-source-filesystem`,
options: {
name: `posts`,
path: `${__dirname}/static/content/collections/posts`,
},
}
上面的代码指示盖茨比在指定路径中查找标记文件,因此请确保您的配置中包含此指令,并且该路径至少包含一个有效的标记文件。我有一个非常愚蠢的错误,在我的标记文件中没有在代码中引用的slug属性。这就是它应该看起来的样子
---
title: Riel's First post
bio: I am a monkey with a dog
slug: "test"
---
Testing
我在上面添加了盖茨比配置文件,我已经有了你建议的所有东西,包括降价文件。奇怪的是,它在某个时候工作正常,然后突然停止,我将更改回滚到工作提交,但仍然是相同的错误。你是否也删除了.cache文件夹和public/?否,我是否应该删除它们并重新运行Gatsby Development我的public/static文件夹为空,如果这很重要的话。更多的是关于我是如何配置我的盖茨比代码的,在我引用东西的过程中需要一个slug。我不建议在你的frontmatter中使用slug。slug已经是一个可以通过graphql获得的现有组件。你应该看看盖茨比博客的例子,看看它是如何做到的。这是我如何做到这一点的一个例子
{
resolve: `gatsby-source-filesystem`,
options: {
name: `posts`,
path: `${__dirname}/static/content/collections/posts`,
},
}
---
title: Riel's First post
bio: I am a monkey with a dog
slug: "test"
---
Testing