tamagui: Error when running yarn ios using starters
Current Behavior
using npm create tamagui@latest --template expo-router and follow the steps to create a project, then run yarn ios to start development via expo go or expo-dev-client, the same error is encountered in both ways
ERROR ReferenceError: Property 'document' doesn't exist, js engine: hermes
at ContextNavigator (http://localhost:8081/node_modules/expo-router/entry.bundle//&platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=com.anonymous.expo-router-example&transform.routerRoot=app&transform.engine=hermes:148411:24)
at ExpoRoot (http://localhost:8081/node_modules/expo-router/entry.bundle//&platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=com.anonymous.expo-router-example&transform.routerRoot=app&transform.engine=hermes:148367:28)
at App
at ErrorToastContainer (http://localhost:8081/node_modules/expo-router/entry.bundle//&platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=com.anonymous.expo-router-example&transform.routerRoot=app&transform.engine=hermes:341210:24)
at ErrorOverlay
at withDevTools(ErrorOverlay) (http://localhost:8081/node_modules/expo-router/entry.bundle//&platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=com.anonymous.expo-router-example&transform.routerRoot=app&transform.engine=hermes:340744:27)
at RCTView
at View (http://localhost:8081/node_modules/expo-router/entry.bundle//&platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=com.anonymous.expo-router-example&transform.routerRoot=app&transform.engine=hermes:40740:43)
at RCTView
at View (http://localhost:8081/node_modules/expo-router/entry.bundle//&platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=com.anonymous.expo-router-example&transform.routerRoot=app&transform.engine=hermes:40740:43)
at AppContainer (http://localhost:8081/node_modules/expo-router/entry.bundle//&platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=com.anonymous.expo-router-example&transform.routerRoot=app&transform.engine=hermes:40551:36)
at main(RootComponent) (http://localhost:8081/node_modules/expo-router/entry.bundle//&platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=com.anonymous.expo-router-example&transform.routerRoot=app&transform.engine=hermes:124413:28)
and then a same error is repeated continuously
λ Bundled 6992ms (node_modules/expo-router/node/render.js)
Web Bundled 7092ms (node_modules/expo-router/entry.js)
λ WARN props.pointerEvents is deprecated. Use style.pointerEvents
λ WARN "shadow*" style props are deprecated. Use "boxShadow".
styleq (node_modules/styleq/dist/styleq.js:62:39)
λ WARN accessibilityRole is deprecated. Use role.
λ WARN accessibilityLabel is deprecated. Use aria-label.
λ WARN Image: style.resizeMode is deprecated. Please use props.resizeMode.
λ WARN Image: style.tintColor is deprecated. Please use props.tintColor.
ERROR There was a problem connecting to the react-native-css-interop Metro server
Expected Behavior
start the project on expo go or expo-dev-client without error
Tamagui Version
1.89.26
Platform (Web, iOS, Android)
iOS
Reproduction
Expo go steps:
1. run `npm create tamagui@latest --template expo-router`
2. select `Expo Router (beta) - Expo Router starter with Tamagui set up`
3. `cd` into the project and run `yarn ios`
4. press `i` to expo-go app in iOS simulator
Dev build step
1. run `npm create tamagui@latest --template expo-router`
2. select `Expo Router (beta) - Expo Router starter with Tamagui set up`
3. run `npx expo run:ios` to create a dev build
4. upon build succeeded, press `i` to launch dev build in iOS simulator
System Info
System:
OS: macOS 14.2.1
CPU: (10) arm64 Apple M1 Pro
Memory: 4.32 GB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 21.1.0 - ~/.nvm/versions/node/v21.1.0/bin/node
Yarn: 4.0.2 - ~/.nvm/versions/node/v21.1.0/bin/yarn
npm: 10.2.0 - ~/.nvm/versions/node/v21.1.0/bin/npm
pnpm: 8.14.1 - /opt/homebrew/bin/pnpm
bun: 1.0.26 - ~/.bun/bin/bun
Watchman: 2023.12.04.00 - /opt/homebrew/bin/watchman
Browsers:
Brave Browser: 119.1.60.118
Chrome: 121.0.6167.184
Safari: 17.2.1
npmPackages:
@babel/core: ^7.23.3 => 7.23.9
@expo/metro-runtime: ~3.1.3 => 3.1.3
@react-navigation/native: ^6.0.2 => 6.1.10
@tamagui/config: ^1.89.26 => 1.89.26
@tamagui/metro-plugin: ^1.89.26 => 1.89.26
@types/react: ~18.2.14 => 18.2.55
babel-preset-expo: ^10.0.1 => 10.0.1
expo: ~50.0.6 => 50.0.6
expo-font: ~11.10.2 => 11.10.2
expo-linking: ~6.2.1 => 6.2.2
expo-router: ~3.4.7 => 3.4.7
expo-splash-screen: ~0.26.4 => 0.26.4
expo-status-bar: ~1.11.1 => 1.11.1
expo-system-ui: ~2.9.3 => 2.9.3
expo-web-browser: ~12.8.2 => 12.8.2
react: ^18.2.0 => 18.2.0
react-dom: ^18.2.0 => 18.2.0
react-helmet-async: ~2.0.4 => 2.0.4
react-native: 0.73.4 => 0.73.4
react-native-reanimated: ~3.6.2 => 3.6.2
react-native-safe-area-context: 4.8.2 => 4.8.2
react-native-screens: ~3.29.0 => 3.29.0
react-native-web: ^0.19.9 => 0.19.10
tamagui: ^1.89.26 => 1.89.26
typescript: ^5.3.3 => 5.3.3
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 12
- Comments: 36 (11 by maintainers)
Same here
I’ll check that over weekend
if you want to add Tamagui to an existing project make sure to follow Tamagui expo router starter and apply same changes! as this tamagui starter is working fine, I’ll close this issue as done
@rlee1990 That’s because you’re using
importInstead, try:I’m getting the error if I add
import '@tamagui/core/reset.css';orimport '../tamagui-web.css';intoapp/_layout.tsxIf I delete that, the error is gone.
I’m still experiencing the same issue with the
import '../tamagui-web.css'despite upgrading my Tamagui versionThere is a fix for windows users on master branch, and will be available with next release
@TheEhsanSarshar I created a new Expo project with
npx create-expo-app --template(File based router), then followed the instructions on https://tamagui.dev/docs/guides/expo to add Tamagui to the project, and I’m getting the same endless stream ofThere was a problem connecting to the react-native-css-interop Metro serverin the console.Here’s my example project: https://github.com/kasparas-ban/tamagui-test
this error still keeps repeating in the terminal:
ERROR There was a problem connecting to the react-native-css-interop Metro serverSame issue here🙋 My workaround is comment this line in
app/_layout.tsx:I just upgraded to the latest
1.102.2tamagui suite version, nothing changes.expo sdk version is 51.0.21
@ddikodroid +1 on removing the css imports.
this issue should be re-opened.
error i got before removing:
Got the same problem when running the project on macos with version
1.90.14. The same result after updating to the newest version1.91.3. - Any workarounds? On Windows it works with1.90.14- with1.91.3haven’t tested yet.I created the project using command from tamagui official website
npm create tamagui@latest --template expo-routerI got the same problem, with template created 2 days ago My workaround was to dynamically import the css in app/_layout.tsx:
And the application seems to work fine in android. At least the error doesn’t show. But I don’t know how this impact in tamagui correct functionality.
TL;DR
I just solved the
ERROR There was a problem connecting to the react-native-css-interop Metro serveradding at the end of metro.config.js file:Explanation
I had my project already created with default’s Expo template, so I had to configure Tamagui from scratch. I followed the official tamagui expo guide. I did eeeverything exactly as says, but unfortunately I ran into that anoying metro error.
Reading your responses here, I saw some of you pointing out that the latest Tamagui expo template had no issues, so I just created one and compared with mine.
After adding Tamagui Metro’s config to my
metro.config.js, it looked like this:And the only difference with Tamagui’s template were two lines:
I don’t know what they do nor where they come from, I just did some testing with one and another line, and I could prove that the solution was the
module.exports = config. In case you wonder what I did with the other lineconfig.resolver.sourceExts.push('mjs'), I am leaving it anyway just in case 😃Hope that helps you!
same issue,
does anyone know stable solution?
UPDATE: if you see similar error with this .css file, try to update bebel.config.js
also, add in metro.config.js
I had the
ERROR ReferenceError: Property 'document' doesn't exist, js engine: hermestoo. I don’t know if the reasons are the same, but I found out that there is a filenode_modules/@tamagui/constants/dist/esm/index.mjsthat exports"./constants.mjs". The constants file is where a variable namedisClientis defined. But exporting"./constants.mjs"(whereisClientis set totrue) makes the resolver ignoring the"./constants.native.mjs"(whereisClientis set tofalse). Replacingexport * from "./constants.mjs";byexport * from "./constants";fixed this error for me.Update
Instead of patching the dependency, I wrote a custom resolver for Metro:
I know this is pretty frustrating for maintainers to ear because it is more of the same. However, I too am getting this issue. Unfortunatly, I can’t give you much context as I am new to React-Native/Expo/Tamagui ecosystem. I was just following along with a YouTube course and decide to use
tamaguiinstead ofNativeWindwhen they suggested adding the style system. The reason simple being, I am looking forward to use Tamagui in the future and because I felt very comfortable withPandaCSSinionicand web land.Like some users above, I only have this problem when I add
webandcssimports inapp/_layout.tsx. The solution proposed by @giornn0 worked for me. Since mypackage.jsondoes not explicitly set"type": "module"and mytsconfig.jsondoes not set the"module"property. I had to use require statements instead.Would this cause uninteded side-effects on Tamagui?
although I wasn’t able to reproduce it with Tamagui official starter, yeah I’ll check it again, maybe something is broken since then