我正在使用gatsby初学者博客模板,我成功地从内容中获得了丰富的文本,并将其显示在页面上。我现在正在尝试做同样的事情,但是使用减价,但是我得到了一个错误"NetworkError,当我试图获取资源“。我的graphql查询。
我试图在这里跟踪文档,所以首先,我有一个很长的文本字段,用于将标记存储在名为"bodym“的内容中。

我的GraphQL查询如下,我基本上是在遵循示例。我能从满足感中打听出这句话。

但是,当试图将其转换为可用的HTML时,我会得到以下错误:

我在控制台中得到了以下内容:
ERROR
The "path" argument must be of type string. Received type undefined
Error: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Recei ved type undefined
- validators.js:125 validateString
internal/validators.js:125:11
- index.js:68 _callee$
[faesel-blog]/[gatsby-remark-relative-images]/index.js:68:40
- index.js:5 asyncGeneratorStep
[faesel-blog]/[gatsby-remark-relative-images]/index.js:5:103
- index.js:7 _next
[faesel-blog]/[gatsby-remark-relative-images]/index.js:7:194
- index.js:7
[faesel-blog]/[gatsby-remark-relative-images]/index.js:7:364
- new Promise
- index.js:7
[faesel-blog]/[gatsby-remark-relative-images]/index.js:7:97
- index.js:96
[faesel-blog]/[gatsby-remark-relative-images]/index.js:96:22
- new Promise
- index.js:47
[faesel-blog]/[gatsby-remark-relative-images]/index.js:47:12
- Array.map
- index.js:46 module.exports
[faesel-blog]/[gatsby-remark-relative-images]/index.js:46:22我的代码可以找到这里。
考虑到我能从满足感中收回减价。我猜问题就在gatsby-source-contentful插件的某个地方。感谢你的帮助!
发布于 2020-06-27 17:41:21
我发现这是包依赖关系的一个问题,代码库最初来自一个gatsby启动程序,为了解决这个问题,我将包依赖项更改为:
"dependencies": {
"@contentful/rich-text-from-markdown": "^14.1.1",
"@contentful/rich-text-react-renderer": "^13.2.0",
"gatsby": "^2.3.3",
"gatsby-plugin-react-helmet": "^3.0.12",
"gatsby-plugin-sass": "^2.0.11",
"gatsby-plugin-sharp": "^2.0.32",
"gatsby-remark-images": "^3.0.10",
"gatsby-remark-relative-images": "^0.2.2",
"gatsby-source-contentful": "^2.0.47",
"gatsby-source-filesystem": "^2.0.28",
"gatsby-transformer-remark": "^2.3.8",
"node-sass": "^4.11.0",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-helmet": "^5.2.0"
},然后将依赖项升级到以下内容:
"dependencies": {
"@contentful/rich-text-from-markdown": "^14.1.1",
"@contentful/rich-text-react-renderer": "^13.4.0",
"gatsby": "^2.23.11",
"gatsby-plugin-react-helmet": "^3.3.6",
"gatsby-plugin-sass": "^2.3.6",
"gatsby-plugin-sharp": "^2.6.14",
"gatsby-remark-images": "^3.3.13",
"gatsby-remark-relative-images": "^0.2.3",
"gatsby-source-contentful": "^2.3.18",
"gatsby-source-filesystem": "^2.3.14",
"gatsby-transformer-remark": "^2.8.19",
"node-sass": "^4.14.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-helmet": "^5.2.1"
}这似乎解决了这个问题。
https://stackoverflow.com/questions/62383809
复制相似问题