react-native-reanimated: Can't run `npx expo start`, Babel plugin exception

Description

I have this error everytime I try start the mobile :

node_modules/react-native-reanimated/src/reanimated2/threads.ts: [Reanimated] Babel plugin exception: ReferenceError: unknown node of type "TSInstantiationExpression" with constructor "Node"

I tried to follow this but it doesn’t resolve the problem.

package.json:

{
  "name": "@airneis/mobile",
  "version": "0.1.0",
  "private": true,
  "main": "expo-router/entry",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "typecheck": "tsc --noEmit"
  },
  "dependencies": {
    "@airneis/api": "^0.1.0",
    "@airneis/schemas": "^0.1.0",
    "@airneis/utils": "^0.1.0",
    "@expo/vector-icons": "^14.0.0",
    "@react-navigation/drawer": "^6.6.9",
    "@react-navigation/native": "^6.1.9",
    "@tanstack/react-query": "^4.36.1",
    "@trpc/react-query": "^10.45.0",
    "clsx": "^2.1.0",
    "expo": "~50.0.15",
    "expo-font": "~11.10.3",
    "expo-linking": "~6.2.2",
    "expo-router": "~3.4.8",
    "expo-secure-store": "~12.8.1",
    "expo-splash-screen": "~0.26.4",
    "expo-status-bar": "~1.11.1",
    "expo-system-ui": "~2.9.3",
    "expo-web-browser": "~12.8.2",
    "lucide-react-native": "^0.341.0",
    "nativewind": "^4.0.22",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-native": "0.73.6",
    "react-native-gesture-handler": "~2.14.0",
    "react-native-reanimated": "~3.6.2",
    "react-native-safe-area-context": "4.8.2",
    "react-native-screens": "~3.29.0",
    "react-native-web": "~0.19.10",
    "superjson": "^2.2.1",
    "zod": "^3.22.4",
    "zustand": "^4.5.1"
  },
  "devDependencies": {
    "@babel/core": "^7.23.9",
    "@types/react": "~18.2.52",
    "react-test-renderer": "18.2.0",
    "tailwindcss": "^3.4.1",
    "typescript": "^5.3.3"
  },
  "overrides": {
    "react-refresh": "~0.14.0"
  },
  "resolutions": {
    "react-refresh": "~0.14.0"
  }
}

babel.config.js:

/** @type {import("@babel/core").ConfigFunction} */
module.exports = (api) => {
  api.cache(true)

  return {
    presets: [
      ["babel-preset-expo", { jsxImportSource: "nativewind" }],
      "nativewind/babel",
    ],
    plugins: ["react-native-reanimated/plugin"],
  }
}

Other information

I’m using a monorepo with npm. It worked 1 month ago. Unfortunately I can’t share the repo but I shared a similar config.

Steps to reproduce

Just run npx expo start

Snack or a link to a repository

https://github.com/Zweird-958/my-wishlist/tree/main/apps/mobile

Reanimated version

3.6.2

React Native version

0.73.6

Platforms

iOS

JavaScript runtime

None

Workflow

Expo Go

Architecture

None

Build type

Debug app & dev bundle

Device

iOS simulator

Device model

iPhone 14 Pro Max (iOS 16.0)

Acknowledgements

Yes

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 26 (2 by maintainers)

Most upvoted comments

Glad to be of help 😄

Well your node_modules/@babel/core/node_modules has its own @babel/traverse etc. which seems to be the source of issues. Try overriding every @babel dependency that’s present there to a single version in your repo. For comparison, this is how node_modules of @babel/core looks in Reanimated’s monorepo:

.
├── .bin
└── semver
    └── bin

I added @babel/generator and @babel/traverse to the resolutions field in my root package.json, and it worked! As a precaution, I also added @babel/core, @babel/types, and @babel/preset-env. I had been facing this issue for almost half a month, but THANKS TO YOU, everything is finally working fine now.

@tjzel My Detox tests fail over hanging animations after I migrated the project from legacy to 2023-11 decorators. I’m certain it’s not an issue with REA but figured I’d ask just in case. Thanks for your quick response! 🙇

@homocodian Did you remember to pass --reset-cache flag?

I was starting dev server with this command bun start -c Where start is “cross-env APP_VARIANT=development expo start”

No, it should be shipped already with some other dependencies, you can check it with npm why @babel/preset-typescript.

This happens when you weren’t updating your locked dependencies for a long time. Try to do it from time to time with npm update.

Okay thank you so much 🙏