software-mansion / react-native-reanimated

React Native's Animated library reimplemented
https://docs.swmansion.com/react-native-reanimated/
MIT License
9.02k stars 1.3k forks source link

Error: Cannot find module 'react-native-reanimated/metro-config' #6507

Closed uhck closed 1 month ago

uhck commented 1 month ago

Description

I installed and followed the setup instructions here: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started

Got to Step 4: clearing the Metro bundler cache Getting error:

Error: Cannot find module 'react-native-reanimated/metro-config'

Steps to reproduce

  1. npm install react-native-reanimated
  2. Added babel plugin: react-native-reanimated/plugin, listed last in babel.config.js
  3. Wrap metro config with reanimated wrapper:
    
    const {
    wrapWithReanimatedMetroConfig,
    } = require('react-native-reanimated/metro-config');

const config = {}; const mergedConfig = mergeConfig(getDefaultConfig(__dirname), config); module.exports = wrapWithReanimatedMetroConfig(mergedConfig);


5. ```npm start -- --reset-cache``` yields the error.

### Snack or a link to a repository

https://github.com/uhck/NotiApp/tree/swiper

### Reanimated version

3.15.2

### React Native version

0.75.2

### Platforms

Android

### JavaScript runtime

None

### Workflow

React Native

### Architecture

None

### Build type

None

### Device

None

### Device model

_No response_

### Acknowledgements

Yes
johnnyrwest commented 1 month ago

@uhck hey, just running into this as well. I found this on Expo's documentation:

https://docs.expo.dev/versions/latest/sdk/reanimated/

It looks like they solved the need for additional configuration in an Expo project.

arnabJ commented 1 month ago

+1

I am on RN 0.75.3 and Reanimated 3.15.2 I don't want to use Expo as RN 0.75.x is still not officially supported in Bare Workflow.

Bumang-Cyber commented 1 month ago

I am on RN 0.75.2 and same thing happened..

uhck commented 1 month ago

@uhck hey, just running into this as well. I found this on Expo's documentation:

https://docs.expo.dev/versions/latest/sdk/reanimated/

It looks like they solved the need for additional configuration in an Expo project.

I'm not working within Expo

MathieuNls commented 1 month ago

I am facing this too. RN 74.5 with expo.

marcpope commented 1 month ago

I am having the exact same problem, just after installing react-native-reanimated.

Bare Workflow Mac Studio M3 with MacOS Sequioa 15 XCode 16

npm 10.2.0 react-native-cli: 2.0.1 react-native: 0.75.3

error Cannot find module 'react-native-reanimated/metro.config' Require stack:

my metro.config.js

// metro.config.js
// per: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started/
const {
    wrapWithReanimatedMetroConfig,
} = require('react-native-reanimated/metro-config');

/**
 * Metro configuration
 * https://reactnative.dev/docs/metro
 *
 * @type {import('metro-config').MetroConfig}
 */

const config = {};

// per: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started/
module.exports = wrapWithReanimatedMetroConfig(config);

Note: If I don't do step3, the app builds. Step 3: Wrap metro config with reanimated wrapper (recommended)

luisjdtt commented 1 month ago

Same thing happening to me. Using bare react native 0.74

androidreactdev commented 1 month ago

Tried with all 3.x.x version but didn't work .. finally had to move to 2.17.0 and working fine react-native :- 0.71.6 react :- 18.2.0

AgusJordi commented 1 month ago

I have the same problem, were you able to find a solution? 🤔🤔

JeffreyVanelderenACA commented 1 month ago

I just removed the wrapWithReanimatedMetroConfig wrapper method in metro.config.js for now... Works fine, it only improves reanimated error messages, hope they still fix it though

AgusJordi commented 1 month ago

In my case I had to check more thoroughly and discovered that the problem actually came from how I was drawing a custom component (a button) and redo that logic to make it work.

MatiPl01 commented 1 month ago

Hey guys!

The new metro config wrapper is only available in nightly version. It will be released when the 3.16.0 is published, so stay tuned!

For now, just please skip this step. Once the new version comes out, you will be able to use this feature.

mhnrcjgs commented 1 month ago

following! I have the same issue. I want to introduce reanimated in my code.

MatiPl01 commented 2 weeks ago

Hey guys!

We finally released the 3.16.0 version where the new metro config wrapper is available. I've just tested on the clean app and it works fine, so you should be able to use it.

Here are two pages in docs that you can refer to:

They are still marked as unreleased because my PR that changes labels is not merged yet but docs are valid now.