React Native项目报错:找不到react-native-reanimated/plugin模块求助
解决"找不到模块'react-native-reanimated/plugin'"的办法
1. 安装/重装react-native-reanimated
先检查项目根目录的package.json,确认是否存在react-native-reanimated依赖。如果没有,执行安装命令:
# npm npm install react-native-reanimated --save-dev # yarn yarn add react-native-reanimated --dev
如果已存在该依赖,先卸载再重装,确保依赖文件完整:
# npm npm uninstall react-native-reanimated && npm install react-native-reanimated --save-dev # yarn yarn remove react-native-reanimated && yarn add react-native-reanimated --dev
2. 修正Babel配置
打开项目根目录的babel.config.js(或.babelrc),确保插件配置正确,且react-native-reanimated/plugin放在plugins数组的最后一位:
module.exports = { presets: ['module:metro-react-native-babel-preset'], plugins: [ // 其他插件 'react-native-reanimated/plugin', ], };
3. 清除缓存并重启服务
执行命令清除Metro缓存,再重启项目服务:
# npm npm start -- --reset-cache # yarn yarn start --reset-cache
4. 手动链接依赖(仅RN 0.60及以下版本)
如果你的React Native版本低于0.60,需要手动链接依赖:
react-native link react-native-reanimated
内容的提问来源于stack exchange,提问作者Prajwal VK
相关产品推荐
相关产品推荐

