React-Native-Reanimated: error: node_modules\react-native-reanimated\src\index.ts:
Asked Answered
P

4

8

I was making new project and I can't run the android emulator with this error.

enter image description here

enter image description here

It is located at 'node_modules\react-native-reanimated\src\index.ts' and this is just the code there:

// tree-shaken side effects
import './reanimated2/js-reanimated/global';

// @ts-ignore backward compatibility with treeshaking
export * from './reanimated1';
export * from './reanimated2';
export * as default from './Animated';

enter image description here

Im not sure what to do, please help. Thank you in advance!

Polled answered 1/8, 2022 at 22:54 Comment(0)
P
11

I also search for an answer and this worked for me.

Visit this expo reanimated docs link https://docs.expo.dev/versions/latest/sdk/reanimated/#installation

and I added this in my 'babel.config.js' file

module.exports = function(api) {
  api.cache(true);
  return {
    presets: ['module:metro-react-native-babel-preset'],
    plugins: ['react-native-reanimated/plugin'],
  };
};

I think the presets depends if you are using expo. Here is the original code given by the docs:

module.exports = function(api) {
  api.cache(true);
  return {
    presets: ['babel-preset-expo'],
    plugins: ['react-native-reanimated/plugin'],
  };
};

you can see that I used my default preset which is module:metro.

Polled answered 1/8, 2022 at 23:8 Comment(1)
I used the original code from the docs for babel.config.js and ran npx expo start --clear which cleared the bundler cache, and everything worked again.Cynthia
P
2

I've been facing this problem for about 12 long hours, and the solution for this problem was simply to

  1. Copy and paste this code below inside the babel.config.js file.
      return {
        presets: ["babel-preset-expo"],
        plugins: ["react-native-reanimated/plugin"],
      };
    };
    
  2. Run your application using npx expo start -c
Photoneutron answered 9/2, 2023 at 16:4 Comment(0)
S
1

I ran this command expo start -c everything was working fine. After that, I've stopped the app with Ctrl+c and run a normal npm start and there were no problems with it since

Symbol answered 25/11, 2022 at 16:43 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Patten
A
0

i have the same issue , This version works for me

    "react-native-reanimated": "2.9.1"
Angloirish answered 17/11, 2022 at 1:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.