Gatsby: 所有gatsby命令的“ StoreStateProvider”模棱两可的错误

创建于 2019-11-27  ·  58评论  ·  资料来源: gatsbyjs/gatsby

描述

将Gatsby从2.17.7更新到2.18.4后,运行任何一种gatsby命令都会导致错误。 但是,实际上没有上下文。

> gatsby clean

The above error occurred in the <StoreStateProvider> component:
    in StoreStateProvider
    in App

React will try to recreate this component tree from scratch using the error boundary you provided, App.
Warning: App: Error boundaries should implement getDerivedStateFromError(). In that method, return a state update to display an error message or fallback UI.
> gatsby build

The above error occurred in the <StoreStateProvider> component:

...

环境

不幸的是,我无法运行gatsby info --clipboard ,因为它崩溃时会出现与其他命令相同的StateStoreProvider错误。 我再次还原了我的Gatsby版本并运行了该命令。 请注意,以下输出中的Gatsby版本不正确

  System:
    OS: Windows 10
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
  Binaries:
    npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD
  Languages:
    Python: 2.7.16 - C:\Python27\python.EXE
  Browsers:
    Edge: 44.18362.267.0
  npmPackages:
    gatsby: ^2.17.7 => 2.17.7
    gatsby-source-apiserver: ^2.1.4 => 2.1.4
stale? needs reproduction bug

最有用的评论

我解决了这个问题! 我使用npm卸载,然后(重新)安装reactreact-domgatsby 。 我是按照确切的顺序进行的(我不认为订购会很重要,但仅供参考)。

npm ls react显示两个版本,但它们相同,并标记为“重复”:

[email protected] <redacted the filepath>
├─┬ [email protected]
│ └─┬ [email protected]
│   └── [email protected]  deduped
└── [email protected]

所有58条评论

从2.17.10更新到2.18.4后,我遇到同样的问题

感谢您的举报!

您还可以尝试升级gatsby-cli吗? 如果这没有帮助,那么如果您可以向我们提供复制存储库,那将非常有帮助。

谢谢! :purple_heart:

我实际上没有全局安装CLI。 该项目依赖于npm run <command>命令,这些命令使用本地安装的Gatsby版本依次执行gatsby <command>

使用该模式,人们无需因全局依赖性而乱抛垃圾。 (如果您从事多个项目(可能需要不同的版本),这可能会变得很丑)

今天早些时候我遇到了类似的问题,对我有用的是更新react,react-dom和gatsby,擦除node_modules和package-lock.json。 最后,我再次运行npm install,一切正常

更新reactreact-dom以及Gatsby似乎可行。 盖茨比不应该列出与其兼容的React的正确版本吗?

昨天我花了半天时间才发现,在我的情况下,用纱线安装Deps时,gatsby build / develop可以正常工作。

似乎与React和Gatsby之间的兼容性问题有关。 如果要从头开始安装依赖项(没有锁定文件),则包管理器(yarn或npm)将仅获取最新版本(受package.json约束)。

就我而言,react版本被锁定在我的package-lock.json ,因此即使在全新安装时也没有与Gatsby一起更新。

我遇到了同样的问题。 我更新了gatsby,gatsby-cli,react和react-dom,但没有成功。 有没有确定的解决方案?

编辑:我删除了gatsby和gatsby-cli并分别重新安装了它们,这似乎已经解决了。 奇怪的问题。

我遇到了这个问题。 这是因为安装了两个版本的react。 运行npm ls react来查看它们。 我在package.json中指定了一个版本的react,并且看起来gatsby / gatsby-cli 2.18.5具有另一个版本的react。

我通过此页面了解到了这个问题。

仍在尝试解决此问题...

我解决了这个问题! 我使用npm卸载,然后(重新)安装reactreact-domgatsby 。 我是按照确切的顺序进行的(我不认为订购会很重要,但仅供参考)。

npm ls react显示两个版本,但它们相同,并标记为“重复”:

[email protected] <redacted the filepath>
├─┬ [email protected]
│ └─┬ [email protected]
│   └── [email protected]  deduped
└── [email protected]

虽然我目前不受阻碍,但我仍然有一些担忧:
1)React的两个版本仍然存在吗? (我不确定),即使它们现在是相同版本
2)将来的gatsby更新是否会再次导致此问题?

没有答案,但请表达我对盖茨比团队考虑的担忧。

我很确定npm ls只是一个工具,可以帮助您了解项目的依赖关系树。 可能只安装了一份react。 您可以进入node_modules文件夹以确保...

更新gatsby之后,我遇到了同样的问题。 我将我的版本降级为“ gatsby”:“ ^ 2.13.73”,这是多个版本,但可以解决此问题。

我解决了这个问题! 我使用npm卸载,然后(重新)安装reactreact-domgatsby 。 我是按照确切的顺序进行的(我不认为订购会很重要,但仅供参考)。

npm ls react显示两个版本,但它们相同,并标记为“重复”:

[email protected] <redacted the filepath>
├─┬ [email protected]
│ └─┬ [email protected]
│   └── [email protected]  deduped
└── [email protected]

这对我有用。 谢谢!

我解决了这个问题! 我使用npm卸载,然后(重新)安装reactreact-domgatsby 。 我是按照确切的顺序进行的(我不认为订购会很重要,但仅供参考)。

npm ls react显示两个版本,但它们相同,并标记为“重复”:

[email protected] <redacted the filepath>
├─┬ [email protected]
│ └─┬ [email protected]
│   └── [email protected]  deduped
└── [email protected]

同上,此解决方案也为我解决了问题。

通过将react和react-dom升级到16.12.0,然后将gatsby升级到2.18.7,我已经成功解决了该问题。

重要提示:确保在升级react,react-dom和gatsby之后运行“ gatsby clean”。

盖茨升级到2.18.7通过@clarmso的建议为我做的伎俩(反应过来是16.12.0)。

也有同样的问题。 更新了react和gatsby,但仍然存在相同的问题。 更新后也尝试清理,问题仍然存在。

“盖茨比”:“ ^ 2.18.11”
“反应”:“ ^ 16.12.0”
“ react-dom”:“ ^ 16.12.0”

也有同样的问题。 更新了react和gatsby,但仍然存在相同的问题。 更新后也尝试清理,问题仍然存在。

“盖茨比”:“ ^ 2.18.11”
“反应”:“ ^ 16.12.0”
“ react-dom”:“ ^ 16.12.0”

我也是。 直到昨天为止一切正常

我解决了这个问题! 我使用npm卸载,然后(重新)安装reactreact-domgatsby 。 我是按照确切的顺序进行的(我不认为订购会很重要,但仅供参考)。

npm ls react显示两个版本,但它们相同,并标记为“重复”:

[email protected] <redacted the filepath>
├─┬ [email protected]
│ └─┬ [email protected]
│   └── [email protected]  deduped
└── [email protected]

这也为我工作。 是否正在为永久修复工作?

由于有了这些更新,我现在收到关于StoreStateProvider的更奇怪的警告,Contentful中的随机事件即使存在,也会返回null。

不知道发生了什么,但我现在必须将其保留在分支上

也有同样的问题。 更新了react和gatsby,但仍然存在相同的问题。 更新后也尝试清理,问题仍然存在。

“盖茨比”:“ ^ 2.18.11”
“反应”:“ ^ 16.12.0”
“ react-dom”:“ ^ 16.12.0”

删除了node_modules文件夹和package-lock.json文件。 跑npm安装,一切都很好。

我的经验是上述评论的结合。 由于我删除了node_modules文件夹并且安装了gatsby插件,因此npm无法正常工作。 纱线安装终于解决了。

我通过重新安装reactreact-domgatsby解决此问题。 (https://github.com/gatsbyjs/gatsby/issues/19827#issuecomment-559898690)

之前

react v16.11.0
react-dom v16.11.0
gatsby v2.17.11

react v16.12.0
react-dom v16.12.0
gatsby v2.18.12

我解决了这个问题! 我使用npm卸载,然后(重新)安装reactreact-domgatsby 。 我是按照确切的顺序进行的(我不认为订购会很重要,但仅供参考)。

npm ls react显示两个版本,但它们相同,并标记为“重复”:

[email protected] <redacted the filepath>
├─┬ [email protected]
│ └─┬ [email protected]
│   └── [email protected]  deduped
└── [email protected]

谢谢,对我有用

我个人必须删除node_modules文件夹和package-lock.json
然后,我升级reactreact-domgatsby

"react": "^16.12.0",
"react-dom": "^16.12.0",
"gatsby": "^2.18.17",

不要忘记将gatsby-cli更新到最新版本并运行gatsby clean
之后, gatsby develop就像一个吊饰!

我发现仅当使用默认的gatsby记录器时才会发生此问题。 通过GATSBY_LOGGER流程env控制将要使用的特定记录器。 如果更改默认记录器(例如使用json记录器),则该问题无法重现。

export GATSBY_LOGGER=["json"]
npm i && npm run start 

切换到yurnalist / json gatsby logger修复问题

export GATSBY_LOGGER=["yurnalist"]

我今天在较旧的项目上运行gatsby develop时遇到了这个问题(上次运行gatsby development的时间是在秋天)

我通过综合以上建议(非常有帮助!)来解决问题。

可以确认这个工作:

  1. gatsby clean -从此开始看是否解决
  2. 删除node_modules
  3. npm install

目前尚未解决,因此我按照建议进行了操作:

  1. npm uninstall react react-dom gatsby
  2. npm install react react-dom gatsby

这工作得很好。

删除package-lock.json
删除的node_modules
我跑了

为我工作:D

我解决了这个问题! 我使用npm卸载,然后(重新)安装reactreact-domgatsby 。 我是按照确切的顺序进行的(我不认为订购会很重要,但仅供参考)。

npm ls react显示两个版本,但它们相同,并标记为“重复”:

[email protected] <redacted the filepath>
├─┬ [email protected]
│ └─┬ [email protected]
│   └── [email protected]  deduped
└── [email protected]

感谢您的解决方案! 这对我来说是一个主要的障碍。 最初它不起作用,但是我也重新安装了gatsby-cli 。 在那之后,它一直运行良好。

描述

将Gatsby从2.17.7更新到2.18.4后,运行任何一种gatsby命令都会导致错误。 但是,实际上没有上下文。

> gatsby clean

The above error occurred in the <StoreStateProvider> component:
    in StoreStateProvider
    in App

React will try to recreate this component tree from scratch using the error boundary you provided, App.
Warning: App: Error boundaries should implement getDerivedStateFromError(). In that method, return a state update to display an error message or fallback UI.
> gatsby build

The above error occurred in the <StoreStateProvider> component:

...

环境

不幸的是,我无法运行gatsby info --clipboard ,因为它崩溃时会出现与其他命令相同的StateStoreProvider错误。 我再次还原了我的Gatsby版本并运行了该命令。 请注意,以下输出中的Gatsby版本不正确

  System:
    OS: Windows 10
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
  Binaries:
    npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD
  Languages:
    Python: 2.7.16 - C:\Python27\python.EXE
  Browsers:
    Edge: 44.18362.267.0
  npmPackages:
    gatsby: ^2.17.7 => 2.17.7
    gatsby-source-apiserver: ^2.1.4 => 2.1.4

我面临着同样的问题! 对我有帮助的解决方案是安装yarn并将resolutions字段添加到您的package.json
https://yarnpkg.com/lang/zh-CN/docs/selective-version-resolutions/

该错误是由于gatsby-cli内部使用reactink呈现新界面的结果。 造成此问题的原因是项目的react版本与gatsby需要的版本之间版本控制不匹配。

据我所知,在全局安装gatsby-cli (我们建议这样做)应该可以防止这些问题。 尽管如此,请关闭此窗口,因为在此方面, gatsby不需要修复任何内容。

非常感谢大家! 💜

昨天我花了半天时间才发现,在我的情况下,用纱线安装Deps时,gatsby build / develop可以正常工作。

有效地使用纱线也为我解决了问题

刚运行npm update为我解决问题

据我所知,全局安装gatsby-cli(我们建议这样做)应该可以防止这些问题。 尽管如此,请关闭此窗口,因为关于此,在盖茨比中不需要修复任何内容。

这对我没有用。 如上所述将记录器切换到yurnalistjson 。 我还删除了public.cachenode_modules文件夹。

gatsby版本的输出:

gatsby -v
Gatsby CLI version: 2.8.27
Gatsby version: 2.18.25

如果好奇,这是我的依赖项:

    "dependencies": {
        "@emotion/core": "^10.0.27",
        "@emotion/styled": "^10.0.27",
        "gatsby": "^2.18.25",
        "gatsby-image": "^2.2.39",
        "gatsby-plugin-emotion": "^4.1.21",
        "gatsby-plugin-google-analytics": "^2.1.33",
        "gatsby-plugin-manifest": "^2.2.37",
        "gatsby-plugin-netlify": "^2.1.31",
        "gatsby-plugin-offline": "^3.0.32",
        "gatsby-plugin-react-helmet": "^3.1.21",
        "gatsby-plugin-sharp": "^2.3.13",
        "gatsby-plugin-web-font-loader": "^1.0.4",
        "gatsby-remark-images": "^3.1.42",
        "gatsby-remark-prismjs": "^3.3.30",
        "gatsby-remark-reading-time": "^1.1.0",
        "gatsby-source-filesystem": "^2.1.46",
        "gatsby-transformer-remark": "^2.6.48",
        "gatsby-transformer-sharp": "^2.3.13",
        "prism-themes": "^1.3.0",
        "prismjs": "^1.19.0",
        "prop-types": "^15.7.2",
        "react": "^16.12.0",
        "react-dom": "^16.12.0",
        "react-helmet": "^5.2.1",
        "typeface-karla": "0.0.72"
    },

这是我收到的错误:

gatsby develop

 ERROR 

The above error occurred in the <StoreStateProvider> component:
    in StoreStateProvider
    in App

React will try to recreate this component tree from scratch using the error boundary you provided, App.


 ERROR 

Warning: App: Error boundaries should implement getDerivedStateFromError(). In that method, return a state update to display an error message or fallback UI.


 ERROR 

UNHANDLED REJECTION Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.



  Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could   happen for one of the following reasons:
  1. You might have mismatching versions of React and the renderer (such as React DOM)
  2. You might be breaking the Rules of Hooks
  3. You might have more than one copy of React in the same app
  See https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.

  - react.development.js:1590 resolveDispatcher
    [project]/[gatsby]/[react]/cjs/react.development.js:1590:13

  - react.development.js:1618 useState
    [project]/[gatsby]/[react]/cjs/react.development.js:1618:20

  - context.js:17 StoreStateProvider
    [project]/[gatsby]/[gatsby-cli]/lib/reporter/loggers/ink/context.js:17:41

  - react-reconciler.development.js:6036 renderWithHooks
    [project]/[react-reconciler]/cjs/react-reconciler.development.js:6036:18

  - react-reconciler.development.js:8570 mountIndeterminateComponent
    [project]/[react-reconciler]/cjs/react-reconciler.development.js:8570:13

  - react-reconciler.development.js:9938 beginWork$1
    [project]/[react-reconciler]/cjs/react-reconciler.development.js:9938:16

  - react-reconciler.development.js:11563 Object.invokeGuardedCallbackImpl
    [project]/[react-reconciler]/cjs/react-reconciler.development.js:11563:10

  - react-reconciler.development.js:11740 invokeGuardedCallback
    [project]/[react-reconciler]/cjs/react-reconciler.development.js:11740:31

  - react-reconciler.development.js:15778 beginWork$$1
    [project]/[react-reconciler]/cjs/react-reconciler.development.js:15778:7

  - react-reconciler.development.js:14696 performUnitOfWork
    [project]/[react-reconciler]/cjs/react-reconciler.development.js:14696:12

要绝望的开发人员寻找根本不应该存在的问题,只需:

-删除node_modules文件夹
-删除package.lock.json
-运行npm我

在获得复制盒后:

这似乎来自npm安装的情况,即用户定义的react安装在node_modules ,而gatsby-cli版本的react将安装在node_modules/gatsby/node_modules

由于ink似乎安装在node_modulesreact导入将使用与gatsby-cli不同的导入,这导致了情况:

  1. 您可能在同一应用中拥有多个React副本
    有关如何调试和解决此问题的提示,请参阅https://fb.me/react-invalid-hook-call

并且https://reactjs.org/warnings/invalid-hook-call-warning.html#duplicate -react很好地解释了这一点,但仅在此建议(使用yarn resolutions无效,因为这是问题与npm似乎如何决定node_modules结构而不是毛线)

只有现在我想到的解决方案(在那个非常哈克)是重写的Node.js模块的分辨率和硬编码react一个由定义gatsby-cli 。 这样做是可以的(这就是至少在纱线v1中实现PnP的方式)

再多考虑一下-另一个选择是使用gatsby-core-utils createRequireFromPath gatsby-core-utils (https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-core-utils/README .md#createrequirefrompath)并在gatsby-cli中使用它来加载与ink相同版本的react(这显着降低了hacky的可能性,并且由于过载Node.js模块分辨率而引起潜在问题的可能性也较小) 。

唯一的问题是,如果我们使用第三方的ink组件( ink-spinner现在才是我们使用的组件),并且这些组件将安装在与ink不同的目录中。

我们可以通过在gatsby-cli ink-spinner内销售gatsby-cli并确保不使用第三方组件作为包装来解决这些潜在问题(并全部

---编辑:
需要注意以上几点- ink需要node >= 16.8.0因此我们需要确保在gatsby-cli不使用从react >= 16.8.1开始的功能-因此需要进行更多的研究,但这是有希望的

更新: createRequireFromPath路由将不起作用,因为npm给定dependenciespeerDependenciesnpm不能正确地解析node_modules层次结构peerDependenciesinkgatsby-cli

“快速”更改是降低react版本要求(https://github.com/gatsbyjs/gatsby/pull/21522),以减少发生此问题的情况。

但这并不能完全解决这个问题。 为此,我们可能会在gatsby-cli捆绑适当的react版本,以解决npm无法正确创建node_modules层次结构(或覆盖Node.js模块分辨率,但这是骇客行为,可能会带来无法预料的后果,因此,如果有其他解决方案,我想避免这样做)

另一个更新-我们对gatsby进行了一些更新以限制受其影响的项目-该更新已发布在[email protected] -但它仍然可能需要您重置/删除package-lock.json

如果仍然不能解决问题,则可能是因为react-dom固定了react / react-dom package.json并且版本低于[email protected] -我们尚无此修复程序,但正在研究下一步-可能的解决方法是暂时使用yarn而不是npm (未经验证)。

如果有人对技术感兴趣,请检查我尝试修复的初始Pull Request的注释-https : //github.com/gatsbyjs/gatsby/pull/21508#issuecomment -586753917,现在的计划是使用某些捆绑软件(可能是microbundle )将react捆绑到gatsby-cli这样它就不会尝试使用node_modules react来使用直接包含在gatsby-cli

我尝试了很多这样的评论,但是作为一个在过程的任何部分都没有使用npm ,我想我会写出对我特别有用的东西。

我的设置:

Win10,通过.msi安装了Yarn,通过yarn global通过Gatsby安装yarn

问题:

任何gatsby {command}都会产生StoreStateProvider错误,但npx gatsby {command}起作用。

解:

  1. 删除.cache/node_modules如果存在)。
  2. 确认reactreact-dom已更新,在撰写本文时, "^16.13.0"
  3. 运行yarn global remove gatsby gatsby-cli删除损坏的CLI。
  4. 运行yarn global add gatsby gatsby-cli重新安装CLI。
  5. 运行gatsby -v或另一个gatsby {command} ,它应该可以工作。

输出:

> gatsby -v
Gatsby CLI version: 2.9.0
Gatsby version: 2.19.23

iya!

这个问题已经悄无声息。 幽灵般的安静。 👻

我们遇到了很多问题,因此我们目前在闲置30天后就关闭了问题。 从这里的最新更新已经至少有20天了。
如果我们错过了此问题,或者您想使其保持打开状态,请在此处回复。 您也可以添加标签“ not stale”以保持此问题的开放状态!
谨在此提醒您:解决此问题或其他任何问题的最佳方法是打开请求请求。 请查看gatsby.dev/contribute ,以获取有关打开PR,分类问题和提供帮助的更多信息!

感谢您加入盖茨比社区! 💪💜

即使没有太多活动,我也不认为它是陈旧的

我遇到了同样的问题,我要做的是删除json.lock并运行yarn命令更新依赖项。 一切恢复正常。

我遇到了相同的问题,我先删除了“ node_modules”文件夹和“ package-lock.json”文件,然后删除了“ npm install”命令。

iya!

这个问题已经悄无声息。 幽灵般的安静。 👻

我们遇到了很多问题,因此我们目前在闲置30天后就关闭了问题。 从这里的最新更新已经至少有20天了。
如果我们错过了此问题,或者您想使其保持打开状态,请在此处回复。 您也可以添加标签“ not stale”以保持此问题的开放状态!
谨在此提醒您:解决此问题或其他任何问题的最佳方法是打开请求请求。 请查看gatsby.dev/contribute ,以获取有关打开PR,分类问题和提供帮助的更多信息!

感谢您加入盖茨比社区! 💪💜

又见面了!

在此问题上发生任何事情已有30天了,因此我们友好的邻居机器人(就是我!)将关闭它。
请记住,我只是一个机器人,所以如果我错误地关闭了此问题,我就是HUMAN_EMOTION_SORRY 。 如果您还有其他需要,请随时重新打开此问题或创建一个新问题。
谨在此提醒您:解决此问题或其他任何问题的最佳方法是打开请求请求。 请查看gatsby.dev/contribute ,以获取有关打开PR,分类问题和提供帮助的更多信息!

再次感谢您加入盖茨比社区! 💪💜

:slightly_frowning_face:我仍在使用yurnalist作为默认记录器。 我在这里从未看到有已修复的更新。

要绝望的开发人员寻找根本不应该存在的问题,只需:

-删除node_modules文件夹
-删除package.lock.json
-运行npm我

这对我有用...

卸载并重新安装gatsby (v 2.23.11)对我有用。

使用纱线安装,应该可以

所以我所做的(在阅读完到目前为止的所有内容之后)是我更改了Gatsby 2.18.7的package.json文件中的版本,并运行npm i

仍然遇到这个问题。

$: gatsby -v
Gatsby CLI version: 2.12.66
Gatsby version: 2.23.12

重现步骤:

  1. 使用gatsby new创建新项目
  2. 使用npm i --save node-sass gatsby-plugin-sass安装sass
  3. 运行gatsby develop

结果

$ gatsby develop

 ERROR

The above error occurred in the <StoreStateProvider> component:
    in StoreStateProvider
    in App

React will try to recreate this component tree from scratch using the error boundary you provided, App.


 ERROR

Warning: App: Error boundaries should implement getDerivedStateFromError(). In that method, return a state update to display an error message or fallback UI.


 ERROR

UNHANDLED REJECTION Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.



  Error: Invalid hook call. Hooks can only be called inside of the body of a fun  ction component. This could happen for one of the following reasons:
  1. You might have mismatching versions of React and the renderer (such as Reac  t DOM)
  2. You might be breaking the Rules of Hooks
  3. You might have more than one copy of React in the same app
  See https://fb.me/react-invalid-hook-call for tips about how to debug and fix   this problem.

  - react.development.js:1465 resolveDispatcher
    [bug]/[gatsby]/[react]/cjs/react.development.js:1465:13

  - react.development.js:1496 useState
    [bug]/[gatsby]/[react]/cjs/react.development.js:1496:20

  - context.js:21 StoreStateProvider
    [bug]/[gatsby]/[gatsby-cli]/lib/reporter/loggers/ink/context.js:21:49

  - react-reconciler.development.js:6036 renderWithHooks
    [bug]/[ink]/[react-reconciler]/cjs/react-reconciler.development.js:6036:18

  - react-reconciler.development.js:8570 mountIndeterminateComponent
    [bug]/[ink]/[react-reconciler]/cjs/react-reconciler.development.js:8570:13

  - react-reconciler.development.js:9938 beginWork$1
    [bug]/[ink]/[react-reconciler]/cjs/react-reconciler.development.js:9938:16

  - react-reconciler.development.js:11563 Object.invokeGuardedCallbackImpl
    [bug]/[ink]/[react-reconciler]/cjs/react-reconciler.development.js:11563:10

  - react-reconciler.development.js:11740 invokeGuardedCallback
    [bug]/[ink]/[react-reconciler]/cjs/react-reconciler.development.js:11740:31

  - react-reconciler.development.js:15778 beginWork$$1
    [bug]/[ink]/[react-reconciler]/cjs/react-reconciler.development.js:15778:7

  - react-reconciler.development.js:14696 performUnitOfWork
    [bug]/[ink]/[react-reconciler]/cjs/react-reconciler.development.js:14696:12

通过如上所述执行以下操作来实现说明来解决此问题☝️

所以我所做的(在阅读完到目前为止的所有内容之后)是我更改了Gatsby 2.18.7的package.json文件中的版本并运行了
npm i它起作用

删除.cache和node_modules文件夹以及package-lock.json,然后重新安装对我来说很有效。

我进行了纱线升级,对我有用。

删除node_modules ,npm高速缓存和package-lock.json文件是不切实际的解决方案,因为每次添加插件或任何依赖项都会带来重大变化。

在我的案例中,潜在的问题是,使用gatsby new [path] [starter]调配的新项目在安装了yarn并可用的情况下隐式使用yarn引导依赖项( which yarn返回非空字符串)。 后续尝试使用npm安装插件/依赖项将失败,并出现上述错误,因为npmyarn是互斥的软件包管理解决方案。

对于gatsby cli,最好不要在没有命令行选项请求的情况下默认使用yarn 。 对我来说,解决方案是卸载yarn并重新初始化项目,以便可以单独使用npm

https://github.com/gatsbyjs/gatsby/pull/26887 (昨天合并,今天发布)从gatsby-cli依赖项中删除react gatsby-cli ,而是在发布程序包时将其捆绑了-这是什么意思是说,它不应该导致怪异的多个副本reactnode_modules ,使得所有排序的问题。

@ duchess-toffee您可能会发现https://github.com/gatsbyjs/gatsby/pull/26856有趣(尚未合并/发布)-虽然它不会自动从yarn还原为npm作为默认软件包管理器-您将能够运行gatsby options set pm npm

我遇到了一个与此问题似乎有关的问题#26998

使用自定义webpack配置解决了react

``js
//文件:gatsby-node.js
const path = require('path')

module.exports = {
onCreateWebpackConfig:({操作})=> {
actions.setWebpackConfig({
解决:{
别名:{
'反应':path.resolve(path.join(__ dirname,'node_modules','react'))
}
}
})
}
}
``

json // file: package.json { "dependencies": { "@mdx-js/mdx": "^1.6.18", "@mdx-js/react": "^1.6.18", "gatsby": "^2.24.64", "gatsby-plugin-layout": "^1.3.11", "gatsby-plugin-mdx": "^1.2.40", "gatsby-plugin-sass": "^2.3.12", "gatsby-source-filesystem": "^2.3.30", "gatsby-telemetry": "^1.3.35", "node-sass": "^4.14.1", "react": "^16.13.1", "react-dom": "^16.13.1", "react-ionicons-v5": "^1.2.0", "three": "^0.120.1" } }

现在一切运行顺利。

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

kalinchernev picture kalinchernev  ·  3评论

jimfilippou picture jimfilippou  ·  3评论

ghost picture ghost  ·  3评论

dustinhorton picture dustinhorton  ·  3评论

Oppenheimer1 picture Oppenheimer1  ·  3评论