software-mansion / react-native-reanimated

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

Can't run `npx expo start`, Babel plugin exception #5883

Closed Zweird-958 closed 5 months ago

Zweird-958 commented 5 months ago

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

tjzel commented 5 months ago

Hi @Zweird-958, as per similar issues, it seems like an outdated @babel/preset-typescript and/or alike dependencies. Usually what worked for people was removing the package manager cache, removing node_modules and package-lock.json.

In your project root: npm cache clean --force && rm -fr node_modules package.lock.json && npm install

Zweird-958 commented 5 months ago

npm cache clean --force && rm -fr node_modules package.lock.json && npm install

I don't know why with this comman it's works. Thanks !

Should I need do npm i -D @babel/preset-typescript ?

tjzel commented 5 months ago

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.

Zweird-958 commented 5 months ago

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 🙏

redreceipt commented 2 months ago

I'm having a similar issue. yarn why @babel/preset-typescript comes up empty from the root and I've run yarn upgrade with no luck. Any help with debugging would be greatly appreciated. I'm also on RN 73 and reanimated 3.6.3 after upgrading from Expo SDK 49 -> 50.

I'm getting the same error except without the with constructor "Node" part

Zweird-958 commented 2 months ago

I'm having a similar issue. yarn why @babel/preset-typescript comes up empty from the root and I've run yarn upgrade with no luck. Any help with debugging would be greatly appreciated. I'm also on RN 73 and reanimated 3.6.3 after upgrading from Expo SDK 49 -> 50.

I'm getting the same error except without the with constructor "Node" part

Doesn't have this issue by using pnpm.