将 gatsby 从版本 2 迁移到版本 4 时出现构建错误
Build error while migrating gatsby from version 2 to 4
我正在将我的网站从 gatsby 2 迁移到版本 4。它 运行 与 gatsby develop
完美搭配。但是,当我运行 gatsby build
时,我得到了以下错误
Error [ERR_IPC_CHANNEL_CLOSED]: Channel closed
at process.target.send (internal/child_process.js:705:16)
at onResult (/Users/h/Desktop/a/node_modules/gatsby-worker/dist/child.js:38:5)
Emitted 'error' event on process instance at:
{
code: 'ERR_IPC_CHANNEL_CLOSED'
}
/Users/h/Desktop/a/node_modules/yoga-layout-prebuilt/yoga-layout/build/Release/nbind.js:53
throw ex;
^
Error [ERR_IPC_CHANNEL_CLOSED]: Channel closed
at process.target.send (internal/child_process.js:705:16)
at onResult (/Users/h/Desktop/a/node_modules/gatsby-worker/dist/child.js:38:5)
Emitted 'error' event on process instance at:
{
code: 'ERR_IPC_CHANNEL_CLOSED'
}
/Users/h/Desktop/a/node_modules/yoga-layout-prebuilt/yoga-layout/build/Release/nbind.js:53
throw ex;
^
Error [ERR_IPC_CHANNEL_CLOSED]: Channel closed
at process.target.send (internal/child_process.js:705:16)
at onResult (/Users/h/Desktop/a/node_modules/gatsby-worker/dist/child.js:38:5)
Emitted 'error' event on process instance at:
{
code: 'ERR_IPC_CHANNEL_CLOSED'
}
您知道此错误的含义以及可能的修复方法吗?
由于某些原因,当我将网站迁移到 gatsby 4 时,构建时间急剧增加
Gatsby 2: Done building in 182.340403886 sec
After upgrading to Gatsby 4: Done building in 385.763567997 sec
我在构建网站时也收到了这些警告
<w> [webpack.cache.PackFileCacheStrategy] Caching failed for pack: Error: Can't resolve '/Users/ht/Desktop/a/gatsby-node.js' in '/Users/ht/Desktop/a'
<w> while resolving '/Users/ht/Desktop/a/gatsby-node.js' in /Users/ht/Desktop/a as file
⠏ Building Rendering Engines
<w> [webpack.cache.PackFileCacheStrategy] Serializing big strings (2076kiB) impacts deserialization performance (consider using Buffer instead and decode when needed)
盖茨比信息
System:
OS: macOS 11.3.1
CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
Shell: 5.8 - /bin/zsh
Binaries:
Node: 14.15.0 - ~/.nvm/versions/node/v14.15.0/bin/node
npm: 6.14.8 - ~/.nvm/versions/node/v14.15.0/bin/npm
Languages:
Python: 2.7.16 - /usr/bin/python
Browsers:
Chrome: 97.0.4692.99
Firefox: 96.0.2
Safari: 14.1
npmPackages:
gatsby: ^4.5.2 => 4.6.0
gatsby-background-image: 1.5.3 => 1.5.3
gatsby-cli: ^3.1.0 => 3.14.2
gatsby-plugin-emotion: ^7.6.0 => 7.6.0
gatsby-plugin-feed: ^4.5.0 => 4.6.0
gatsby-plugin-google-tagmanager: ^4.5.0 => 4.6.0
gatsby-plugin-image: ^2.5.2 => 2.6.0
gatsby-plugin-lodash: ^5.5.0 => 5.6.0
gatsby-plugin-manifest: ^4.5.2 => 4.6.0
gatsby-plugin-react-helmet: ^5.5.0 => 5.6.0
gatsby-plugin-remove-trailing-slashes: ^4.5.0 => 4.6.0
gatsby-plugin-robots-txt: ^1.5.5 => 1.7.0
gatsby-plugin-sentry: ^1.0.1 => 1.0.1
gatsby-plugin-sharp: ^4.5.2 => 4.6.0
gatsby-plugin-sitemap: ^5.5.0 => 5.6.0
gatsby-plugin-typegen: ^2.2.4 => 2.2.4
gatsby-plugin-typescript: ^4.5.2 => 4.6.0
gatsby-remark-external-links: 0.0.4 => 0.0.4
gatsby-source-contentful: ^7.3.2 => 7.4.0
gatsby-source-filesystem: ^4.5.2 => 4.6.0
gatsby-source-workable: ^1.1.1 => 1.1.1
gatsby-transformer-remark: ^5.5.2 => 5.6.0
gatsby-transformer-sharp: ^4.5.0 => 4.6.0
=======================
如果构建成功,我就有了缓存版本。如果我在不清理缓存的情况下再次构建站点,我会收到此错误
Encountered an error trying to infer a GraphQL type for: `tagsList___NODE`. There is no corresponding node with the `id` field matching: "10d9531b-cc34-585e-a658-d2bb37977bef,520da789-a4c8-5465-af81-ae9e75d96123,c6c2bd79-1917-5fe8-848d-634c9ea702ce,d16915b0-7e55-5aca-9992-3d8
a780fe7ff,b4e89f32-400e-57a6-aa56-efe29657eae5,f7f9642e-b7c1-5c09-a08e-6bba3f96fa41,96c01237-f7cf-5f35-ad5c-0e05dfbc73cb,d90ffcca-762f-53bc-bd24-ee95402825e7,9d846575-611d-5f13-9002-7061fa697e24,08c8df32-e25b-5242-9f8a-3c429055d998,43475632-a0e5-5e24-a826-d01ce53ff7a4".
Error: Invariant Violation: Encountered an error trying to infer a GraphQL type for: `tagsList___NODE`. There is no corresponding node with the `id` field matching: "10d9531b-cc34-585e-a658-d2bb37977bef,520da789-a4c8-5465-af81-ae9e75d96123,c6c2bd79-1917-5fe8-848d-634c9ea702
ce,d16915b0-7e55-5aca-9992-3d8a780fe7ff,b4e89f32-400e-57a6-aa56-efe29657eae5,f7f9642e-b7c1-5c09-a08e-6bba3f96fa41,96c01237-f7cf-5f35-ad5c-0e05dfbc73cb,d90ffcca-762f-53bc-bd24-ee95402825e7,9d846575-611d-5f13-9002-7061fa697e24,08c8df32-e25b-5242-9f8a-3c429055d998,43475632-a0e
5-5e24-a826-d01ce53ff7a4".
什么是tagsList___NODE?
Contentful 中的 My Page 内容模型有一个名为 'Tags list' 的字段,它引用 Tag 模型。它与 Gatsby 版本 2 完美配合。
然后我在代码中查询tagsList
const productsData = await graphql<any>(`
query {
allContentfulPageProduct(filter: { page: { elemMatch: { slug: { ne: null } } } }) {
nodes {
externalId
page {
slug
tagsList {
name
}
}
blogSlugs
}
}
}
`);
Gatsby/gatsby-source-contentful 自动为我创建了一个架构
type ContentfulTag implements ContentfulReference & ContentfulEntry & Node @derivedTypes @dontInfer {
contentful_id: String!
node_locale: String!
name: String
page: [ContentfulPage] @link(by: "id", from: "page___NODE")
spaceId: String
createdAt: Date @dateformat
updatedAt: Date @dateformat
sys: ContentfulTagSys
}
type ContentfulPage implements ContentfulReference & ContentfulEntry & Node @derivedTypes @dontInfer {
contentful_id: String!
node_locale: String!
metaTitle: String
slug: String
content: ContentfulPageAboutContentfulPageBusinessValueCalculatorContentfulPageCareersContentfulPageCaseStudiesContentfulPageCloudContentfulPageClusterContentfulPageDevopsContentfulPageExpPostgresqlContentfulPageHomeContentfulPageIntegrationsContentfulPageNewsletterContentfulPageObservabilityContentfulPageOpenSourceContentfulPagePartnersContentfulPagePlansAndPricingContentfulPageProductContentfulPageSecurityAndComplianceContentfulPageSimpleContentContentfulPageSolutionContentfulPageSolutionType3ContentfulPageSolutionsContentfulPageSolutionsRetailContentfulPageTimeSeriesContentfulPageTimeSeriesChild1ContentfulPageTimeSeriesChildPage3ContentfulPageTimeSeriesChildPage4ContentfulPageTimeSeriesResourcesUnion @link(by: "id", from: "content___NODE")
metaDescription: contentfulPageMetaDescriptionTextNode @link(by: "id", from: "metaDescription___NODE")
spaceId: String
createdAt: Date @dateformat
updatedAt: Date @dateformat
sys: ContentfulPageSys
tagsList: [ContentfulTag] @link(by: "id", from: "tagsList___NODE")
}
经过一些调试,根据一些GitHub threads,问题似乎与 Contentful 源插件 (gatsby-source-contentful
) 以及为 tag
节点创建内部 ID 的能力有关(tags___NODE
).
除了等待解决方案,您还可以尝试将插件更新到最新版本。
我正在将我的网站从 gatsby 2 迁移到版本 4。它 运行 与 gatsby develop
完美搭配。但是,当我运行 gatsby build
时,我得到了以下错误
Error [ERR_IPC_CHANNEL_CLOSED]: Channel closed
at process.target.send (internal/child_process.js:705:16)
at onResult (/Users/h/Desktop/a/node_modules/gatsby-worker/dist/child.js:38:5)
Emitted 'error' event on process instance at:
{
code: 'ERR_IPC_CHANNEL_CLOSED'
}
/Users/h/Desktop/a/node_modules/yoga-layout-prebuilt/yoga-layout/build/Release/nbind.js:53
throw ex;
^
Error [ERR_IPC_CHANNEL_CLOSED]: Channel closed
at process.target.send (internal/child_process.js:705:16)
at onResult (/Users/h/Desktop/a/node_modules/gatsby-worker/dist/child.js:38:5)
Emitted 'error' event on process instance at:
{
code: 'ERR_IPC_CHANNEL_CLOSED'
}
/Users/h/Desktop/a/node_modules/yoga-layout-prebuilt/yoga-layout/build/Release/nbind.js:53
throw ex;
^
Error [ERR_IPC_CHANNEL_CLOSED]: Channel closed
at process.target.send (internal/child_process.js:705:16)
at onResult (/Users/h/Desktop/a/node_modules/gatsby-worker/dist/child.js:38:5)
Emitted 'error' event on process instance at:
{
code: 'ERR_IPC_CHANNEL_CLOSED'
}
您知道此错误的含义以及可能的修复方法吗?
由于某些原因,当我将网站迁移到 gatsby 4 时,构建时间急剧增加
Gatsby 2: Done building in 182.340403886 sec
After upgrading to Gatsby 4: Done building in 385.763567997 sec
我在构建网站时也收到了这些警告
<w> [webpack.cache.PackFileCacheStrategy] Caching failed for pack: Error: Can't resolve '/Users/ht/Desktop/a/gatsby-node.js' in '/Users/ht/Desktop/a'
<w> while resolving '/Users/ht/Desktop/a/gatsby-node.js' in /Users/ht/Desktop/a as file
⠏ Building Rendering Engines
<w> [webpack.cache.PackFileCacheStrategy] Serializing big strings (2076kiB) impacts deserialization performance (consider using Buffer instead and decode when needed)
盖茨比信息
System:
OS: macOS 11.3.1
CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
Shell: 5.8 - /bin/zsh
Binaries:
Node: 14.15.0 - ~/.nvm/versions/node/v14.15.0/bin/node
npm: 6.14.8 - ~/.nvm/versions/node/v14.15.0/bin/npm
Languages:
Python: 2.7.16 - /usr/bin/python
Browsers:
Chrome: 97.0.4692.99
Firefox: 96.0.2
Safari: 14.1
npmPackages:
gatsby: ^4.5.2 => 4.6.0
gatsby-background-image: 1.5.3 => 1.5.3
gatsby-cli: ^3.1.0 => 3.14.2
gatsby-plugin-emotion: ^7.6.0 => 7.6.0
gatsby-plugin-feed: ^4.5.0 => 4.6.0
gatsby-plugin-google-tagmanager: ^4.5.0 => 4.6.0
gatsby-plugin-image: ^2.5.2 => 2.6.0
gatsby-plugin-lodash: ^5.5.0 => 5.6.0
gatsby-plugin-manifest: ^4.5.2 => 4.6.0
gatsby-plugin-react-helmet: ^5.5.0 => 5.6.0
gatsby-plugin-remove-trailing-slashes: ^4.5.0 => 4.6.0
gatsby-plugin-robots-txt: ^1.5.5 => 1.7.0
gatsby-plugin-sentry: ^1.0.1 => 1.0.1
gatsby-plugin-sharp: ^4.5.2 => 4.6.0
gatsby-plugin-sitemap: ^5.5.0 => 5.6.0
gatsby-plugin-typegen: ^2.2.4 => 2.2.4
gatsby-plugin-typescript: ^4.5.2 => 4.6.0
gatsby-remark-external-links: 0.0.4 => 0.0.4
gatsby-source-contentful: ^7.3.2 => 7.4.0
gatsby-source-filesystem: ^4.5.2 => 4.6.0
gatsby-source-workable: ^1.1.1 => 1.1.1
gatsby-transformer-remark: ^5.5.2 => 5.6.0
gatsby-transformer-sharp: ^4.5.0 => 4.6.0
======================= 如果构建成功,我就有了缓存版本。如果我在不清理缓存的情况下再次构建站点,我会收到此错误
Encountered an error trying to infer a GraphQL type for: `tagsList___NODE`. There is no corresponding node with the `id` field matching: "10d9531b-cc34-585e-a658-d2bb37977bef,520da789-a4c8-5465-af81-ae9e75d96123,c6c2bd79-1917-5fe8-848d-634c9ea702ce,d16915b0-7e55-5aca-9992-3d8
a780fe7ff,b4e89f32-400e-57a6-aa56-efe29657eae5,f7f9642e-b7c1-5c09-a08e-6bba3f96fa41,96c01237-f7cf-5f35-ad5c-0e05dfbc73cb,d90ffcca-762f-53bc-bd24-ee95402825e7,9d846575-611d-5f13-9002-7061fa697e24,08c8df32-e25b-5242-9f8a-3c429055d998,43475632-a0e5-5e24-a826-d01ce53ff7a4".
Error: Invariant Violation: Encountered an error trying to infer a GraphQL type for: `tagsList___NODE`. There is no corresponding node with the `id` field matching: "10d9531b-cc34-585e-a658-d2bb37977bef,520da789-a4c8-5465-af81-ae9e75d96123,c6c2bd79-1917-5fe8-848d-634c9ea702
ce,d16915b0-7e55-5aca-9992-3d8a780fe7ff,b4e89f32-400e-57a6-aa56-efe29657eae5,f7f9642e-b7c1-5c09-a08e-6bba3f96fa41,96c01237-f7cf-5f35-ad5c-0e05dfbc73cb,d90ffcca-762f-53bc-bd24-ee95402825e7,9d846575-611d-5f13-9002-7061fa697e24,08c8df32-e25b-5242-9f8a-3c429055d998,43475632-a0e
5-5e24-a826-d01ce53ff7a4".
什么是tagsList___NODE?
Contentful 中的 My Page 内容模型有一个名为 'Tags list' 的字段,它引用 Tag 模型。它与 Gatsby 版本 2 完美配合。
然后我在代码中查询tagsList
const productsData = await graphql<any>(`
query {
allContentfulPageProduct(filter: { page: { elemMatch: { slug: { ne: null } } } }) {
nodes {
externalId
page {
slug
tagsList {
name
}
}
blogSlugs
}
}
}
`);
Gatsby/gatsby-source-contentful 自动为我创建了一个架构
type ContentfulTag implements ContentfulReference & ContentfulEntry & Node @derivedTypes @dontInfer {
contentful_id: String!
node_locale: String!
name: String
page: [ContentfulPage] @link(by: "id", from: "page___NODE")
spaceId: String
createdAt: Date @dateformat
updatedAt: Date @dateformat
sys: ContentfulTagSys
}
type ContentfulPage implements ContentfulReference & ContentfulEntry & Node @derivedTypes @dontInfer {
contentful_id: String!
node_locale: String!
metaTitle: String
slug: String
content: ContentfulPageAboutContentfulPageBusinessValueCalculatorContentfulPageCareersContentfulPageCaseStudiesContentfulPageCloudContentfulPageClusterContentfulPageDevopsContentfulPageExpPostgresqlContentfulPageHomeContentfulPageIntegrationsContentfulPageNewsletterContentfulPageObservabilityContentfulPageOpenSourceContentfulPagePartnersContentfulPagePlansAndPricingContentfulPageProductContentfulPageSecurityAndComplianceContentfulPageSimpleContentContentfulPageSolutionContentfulPageSolutionType3ContentfulPageSolutionsContentfulPageSolutionsRetailContentfulPageTimeSeriesContentfulPageTimeSeriesChild1ContentfulPageTimeSeriesChildPage3ContentfulPageTimeSeriesChildPage4ContentfulPageTimeSeriesResourcesUnion @link(by: "id", from: "content___NODE")
metaDescription: contentfulPageMetaDescriptionTextNode @link(by: "id", from: "metaDescription___NODE")
spaceId: String
createdAt: Date @dateformat
updatedAt: Date @dateformat
sys: ContentfulPageSys
tagsList: [ContentfulTag] @link(by: "id", from: "tagsList___NODE")
}
经过一些调试,根据一些GitHub threads,问题似乎与 Contentful 源插件 (gatsby-source-contentful
) 以及为 tag
节点创建内部 ID 的能力有关(tags___NODE
).
除了等待解决方案,您还可以尝试将插件更新到最新版本。