我在 Gatsby 中收到 "Invalid Plugin Options" Prismic 插件错误
I get "Invalid Plugin Options" Error with Prismic Plugin in Gatsby
我正在使用 CodeSandbox 制作一个 Gatsby 应用程序,我正在尝试将 Prismic 用于后端。我确定它设置得很好,并且我将 gatsby-source-prismic
安装到我的项目中。但是,当我将它添加到我的配置文件并重新启动项目时,它会抛出一条错误消息 "Invalid Plugin Options"。这是我的插件文件中的内容:
{
resolve: `gatsby-source-prismic`,
options: {
repositoryName: `firstprism`,
accessToken: `XXX`
},
},
这是堆栈:
ERROR
gatsby-source-prismic - 无效的插件选项
错误
schemas
需要 record<string,object>
类型的值,但收到 undefined
。
错误:
index.cjs:650 新结构错误
[沙盒]/[上层结构]/lib/index.cjs:650:19
index.cjs:707Function.Struct.assert
[沙盒]/[上层结构]/lib/index.cjs:707:13
index.cjs:679 结构
[沙盒]/[上层结构]/lib/index.cjs:679:19
gatsby-node.js:74 validatePluginOptions
[沙盒]/[gatsby-source-prismic]/dist/gatsby-node.js:74:50
盖茨比-node.js:1042
[沙盒]/[gatsby-source-prismic]/dist/gatsby-node.js:1042:25
Generator.next
盖茨比-node.js:52
[沙盒]/[gatsby-source-prismic]/dist/gatsby-node.js:52:71
新诺言
盖茨比-node.js:48__awaiter
[沙盒]/[gatsby-source-prismic]/dist/gatsby-node.js:48:12
盖茨比-node.js:1029Object.sourceNodes
[沙盒]/[gatsby-source-prismic]/dist/gatsby-node.js:1029:55
api-runner-node.js:256 runAPI
[沙盒]/[盖茨比]/dist/utils/api-runner-node.js:256:37
api-runner-node.js:375解析
[沙盒]/[盖茨比]/dist/utils/api-runner-node.js:375:15
debuggability.js:384Promise._execute
[沙盒]/[蓝鸟]/js/release/debuggability.js:384:9
promise.js:518Promise._resolveFromExecutor
[沙盒]/[蓝鸟]/js/release/promise.js:518:18
promise.js:103 新承诺
[沙盒]/[蓝鸟]/js/release/promise.js:103:10
api-亚军-node.js:374Promise.mapSeries.plugin
[沙盒]/[盖茨比]/dist/utils/api-runner-node.js:374:12
我刚刚 运行 进入这个问题。看来现在需要提供 JSON 模式,如文档中所述:https://github.com/angeloashmore/gatsby-source-prismic#providing-json-schemas
编辑:另请参考https://github.com/angeloashmore/gatsby-source-prismic/blob/master/docs/migrating-from-v2-to-v3.md
是这样的
options: {
repositoryName: 'your-repository-name',
accessToken: `${process.env.API_KEY}`,
linkResolver: ({ node, key, value }) => post => `/${post.uid}`,
schemas: {
page: require("./src/schemas/page.json"),
},
},
而不是现在
options: {
repositoryName: `your-repository-name`,
accessToken: `${process.env.API_KEY}`,
linkResolver: ({ node, key, value }) => post => `/${post.uid}`,
page: require("./src/schemas/page.json"),
},
我正在使用 CodeSandbox 制作一个 Gatsby 应用程序,我正在尝试将 Prismic 用于后端。我确定它设置得很好,并且我将 gatsby-source-prismic
安装到我的项目中。但是,当我将它添加到我的配置文件并重新启动项目时,它会抛出一条错误消息 "Invalid Plugin Options"。这是我的插件文件中的内容:
{
resolve: `gatsby-source-prismic`,
options: {
repositoryName: `firstprism`,
accessToken: `XXX`
},
},
这是堆栈:
ERROR
gatsby-source-prismic - 无效的插件选项
错误
schemas
需要 record<string,object>
类型的值,但收到 undefined
。
错误:
index.cjs:650 新结构错误 [沙盒]/[上层结构]/lib/index.cjs:650:19
index.cjs:707Function.Struct.assert [沙盒]/[上层结构]/lib/index.cjs:707:13
index.cjs:679 结构 [沙盒]/[上层结构]/lib/index.cjs:679:19
gatsby-node.js:74 validatePluginOptions [沙盒]/[gatsby-source-prismic]/dist/gatsby-node.js:74:50
盖茨比-node.js:1042 [沙盒]/[gatsby-source-prismic]/dist/gatsby-node.js:1042:25
Generator.next
盖茨比-node.js:52 [沙盒]/[gatsby-source-prismic]/dist/gatsby-node.js:52:71
新诺言
盖茨比-node.js:48__awaiter [沙盒]/[gatsby-source-prismic]/dist/gatsby-node.js:48:12
盖茨比-node.js:1029Object.sourceNodes [沙盒]/[gatsby-source-prismic]/dist/gatsby-node.js:1029:55
api-runner-node.js:256 runAPI [沙盒]/[盖茨比]/dist/utils/api-runner-node.js:256:37
api-runner-node.js:375解析 [沙盒]/[盖茨比]/dist/utils/api-runner-node.js:375:15
debuggability.js:384Promise._execute [沙盒]/[蓝鸟]/js/release/debuggability.js:384:9
promise.js:518Promise._resolveFromExecutor [沙盒]/[蓝鸟]/js/release/promise.js:518:18
promise.js:103 新承诺 [沙盒]/[蓝鸟]/js/release/promise.js:103:10
api-亚军-node.js:374Promise.mapSeries.plugin [沙盒]/[盖茨比]/dist/utils/api-runner-node.js:374:12
我刚刚 运行 进入这个问题。看来现在需要提供 JSON 模式,如文档中所述:https://github.com/angeloashmore/gatsby-source-prismic#providing-json-schemas
编辑:另请参考https://github.com/angeloashmore/gatsby-source-prismic/blob/master/docs/migrating-from-v2-to-v3.md
是这样的
options: {
repositoryName: 'your-repository-name',
accessToken: `${process.env.API_KEY}`,
linkResolver: ({ node, key, value }) => post => `/${post.uid}`,
schemas: {
page: require("./src/schemas/page.json"),
},
},
而不是现在
options: {
repositoryName: `your-repository-name`,
accessToken: `${process.env.API_KEY}`,
linkResolver: ({ node, key, value }) => post => `/${post.uid}`,
page: require("./src/schemas/page.json"),
},