无法parsing模块“react / lib / ReactComponentTreeHook”

我正在尝试升级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_modulesfind任何名为ReactComponentTreeHook的库。

我已经尝试删除node_modules文件夹并重新安装,纳达。 我也清除守望者手表,并重置打包器caching。

编辑:我一直遇到问题,似乎源于反应原生地图,所以我所以我重新回到一个工作稳定版本,卸载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" }, 

再次,经历清理守望者手表,节点模块,重置包pipe理器的过程,仍然得到这个错误。

编辑2:花了两天试图让这个工作,我创build了一个新的空白项目,并迁移我的代码。

如果您没有反应原生版本所需的正确反应版本,也可能发生这种情况。 如果是这样的话,当你运行npm install时候,你会得到这样的警告。

 npm WARN react-native@0.43.4 requires a peer of react@16.0.0-alpha.6 but none was installed. 

要解决此问题,请停止反应包装程序并通过运行以下命令来升级反应版本

 npm install -save react@16.0.0-alpha.6 

现在,重新运行应用程序,希望问题会消失。

我认为最近react / lib下的许多模块被移动到react-dom / lib,这就是为什么打包程序找不到一些模块

确保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 xyz(version you want to upgrade to) 

对我来说,它的工作。

如果你的版本太旧,那么你应该按照旧版本的文件进行升级。