gpt4 book ai didi

node.js - 无法解析模块 `react/lib/ReactComponentTreeHook`

转载 作者:太空宇宙 更新时间:2023-11-03 22:51:07 24 4
gpt4 key购买 nike

我正在尝试升级 React Native,但遇到了以下问题:

error: bundling: UnableToResolveError: Unable to resolve module `react/lib/ReactComponentTreeHook` from `/Users/anthony/dev/apptova-react/node_modules/react-native/Libraries/Performance/Systrace.js`: Module does not exist in the module map or in these directories:
/Users/anthony/dev/apptova-react/node_modules/react-native/node_modules/react/lib
, /Users/anthony/dev/apptova-react/node_modules/react/lib

我很困惑。我在 node_modules 中找不到任何名为 ReactComponentTreeHook 的库。

我尝试删除 node_modules 文件夹并重新安装,但没有。我还清除了守望者 watch 并重置了打包器缓存。

编辑:我一直遇到似乎源于react-native-maps的问题,所以我重置回工作稳定版本,卸载react-native-maps,然后运行react- native-git-upgrade(再次)。

现在我得到:

error: bundling: UnableToResolveError: Unable to resolve module `react/lib/ReactDebugCurrentFrame` from `/Users/anthony/dev/apptova-react/node_modules/react-native/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactCompositeComponent.js`: Module does not exist in the module map or in these directories:
/Users/anthony/dev/apptova-react/node_modules/react-native/node_modules/react/lib
, /Users/anthony/dev/apptova-react/node_modules/react/lib

我只是想更新,我的 package.json 依赖项很简单,所以我不认为它与第三方代码库冲突:

"dependencies": {
"react": "15.4.1",
"react-native": "^0.43.1",
"react-native-drawer": "^2.3.0"
},
"devDependencies": {
"babel-jest": "18.0.0",
"babel-plugin-transform-flow-strip-types": "^6.21.0",
"babel-preset-react-native": "1.9.1",
"deepmerge": "^1.3.2",
"flow-bin": "^0.37.4",
"jest": "18.0.0",
"react-test-renderer": "15.4.1"
},

再次经历了清除守望者 watch 、 Node 模块、重置包管理器的过程,但仍然出现此错误。

编辑 2: 在花了整整两天的时间试图让这个工作正常运行之后,我创建了一个新的空白项目并迁移了我的代码。

最佳答案

确保 package.json 文件中的版本是您想要的版本。

例如,“react-native: ^0.43.3”与“react-native: 0.43.3”不同。

清理并重新安装所有内容。

如果错误仍然存​​在,则尝试安装react-native-git-upgrade

$ npm install -g react-native-git-upgrade

然后运行

$ react-native-git-upgrade x.y.z(version you want to upgrade to)

对我来说它有效。

如果您的版本太旧,请按照旧版本文档进行升级。

关于node.js - 无法解析模块 `react/lib/ReactComponentTreeHook`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43743314/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com