错误:错误:无法解析来自 /node_modules/react-native-reanimated/src/reani



我是新安装的 React Native Reanimation 2.3.0-beta.1,并且已经按照文档中的设置进行操作。

"react-native-gesture-handler": "^1.10.3",
"react-native-reanimated": "^2.3.0-beta.2",

启动我的应用时,会出现以下错误:

error: Error: Unable to resolve module ./Hooks from /ProjectName/node_modules/react-native-reanimated/src/reanimated2/index.ts: 
None of these files exist:
* node_modules/react-native-reanimated/src/reanimated2/Hooks(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.svg|.native.svg|.svg)
* node_modules/react-native-reanimated/src/reanimated2/Hooks/index(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.svg|.native.svg|.svg)
> 1 | export * from './core';
2 | export * from './hook';
3 | export * from './animation';
4 | export * from './interpolation';
at ModuleResolver.resolveDependency (/ProjectName/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:107:15)
at DependencyGraph.resolveDependency (/ProjectName/node_modules/metro/src/node-haste/DependencyGraph.js:288:43)
at Object.resolve (/ProjectName/node_modules/metro/src/lib/transformHelpers.js:129:24)
at resolve (/ProjectName/node_modules/metro/src/DeltaBundler/traverseDependencies.js:396:33)
at /ProjectName/node_modules/metro/src/DeltaBundler/traverseDependencies.js:412:26
at Array.reduce (<anonymous>)
at resolveDependencies (/ProjectName/node_modules/metro/src/DeltaBundler/traverseDependencies.js:411:33)
at processModule (/ProjectName/node_modules/metro/src/DeltaBundler/traverseDependencies.js:140:31)
at async addDependency (/ProjectName/node_modules/metro/src/DeltaBundler/traverseDependencies.js:230:18)
at async Promise.all (index 6)

任何帮助将不胜感激!

我相信您收到了有关按照在 React Native 应用程序上安装react-native-reanimated的说明进行操作的警告消息,并决定按照他们的说明进行操作 https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation

这是我的情况,一旦我做了他们要求我做的所有事情,我就开始收到此错误。

这是我为解决此问题所做的:

  1. 首先,我没有按照他们的建议安装react-native-reanimated@next安装2.3.0-beta2,而是安装了最新的稳定版本,该版本2.2.3
  2. 然后我测试了它,这使问题消失了,但随后我的应用程序一直冻结。然后我决定撤消他们说明中的另一个步骤,并在android/app/build.gradle中设置enableHermes: false

这为我解决了问题。

通过执行以下命令重置 JavaScript 缓存:

npx react-native start --reset-cache

相关内容

  • 没有找到相关文章

最新更新