tamagui: [Expo][Vercel] Unable to resolve module /vercel/path0/.tamagui/css/...

Current Behavior

When deploying an expo app to Vercel from the local machine using vercel cli (vercel --prod), everything is ok. But when Vercel builds the project via CI/CD on a commit, it fails with the following error:

➤ YN0000: │ my-app@workspace:. STDOUT     ➡ [tamagui] built config and components (5809ms):
--
13:46:39.461 | ➤ YN0000: │ my-app@workspace:. STDOUT
13:46:39.461 | ➤ YN0000: │ my-app@workspace:. STDOUT         Config     ./.tamagui/tamagui.config.cjs
13:46:39.461 | ➤ YN0000: │ my-app@workspace:. STDOUT         Components ./.tamagui/tamagui-components.config.cjs
13:46:39.461 | ➤ YN0000: │ my-app@workspace:. STDOUT
13:46:44.953 | ➤ YN0000: │ my-app@workspace:. STDOUT     ➡ [tamagui] output css: ./tamagui-web.css
13:46:44.954 | ➤ YN0000: │ my-app@workspace:. STDOUT
13:46:45.374 | ➤ YN0000: │ my-app@workspace:. STDOUT ✔ Check that packages match versions required by installed Expo SDK
13:46:52.443 | ➤ YN0000: │ my-app@workspace:. STDOUT ✔ Check for legacy global CLI installed locally
13:46:52.905 | ➤ YN0000: │ my-app@workspace:. STDOUT ✔ Check that native modules do not use incompatible support packages
13:46:54.907 | ➤ YN0000: │ my-app@workspace:. STDOUT ✔ Check that native modules use compatible support package versions for installed Expo SDK
13:46:54.914 | ➤ YN0000: │ my-app@workspace:. STDOUT
13:46:54.915 | ➤ YN0000: │ my-app@workspace:. STDOUT Didn't find any issues with the project!
13:46:54.939 | ➤ YN0000: └ Completed in 42s 172ms
13:46:55.120 | ➤ YN0000: · Done in 1m 24s
13:46:56.223 | env: load .env
13:46:56.224 | env: export EXPO_PUBLIC_APPCHECK_SITE_KEY
13:46:57.120 | Starting Metro Bundler
13:46:57.959 |  
13:46:57.960 | ➡ [tamagui] built config and components (1215ms):
13:46:57.960 |  
13:46:57.960 | Config     ./.tamagui/tamagui.config.cjs
13:46:57.960 | Components ./.tamagui/tamagui-components.config.cjs
13:46:57.960 |  
13:46:58.380 | ➡ [tamagui] output css: ./tamagui-web.css
13:46:58.380 |  
13:47:22.498 | web  \|               conjugation   ·    1 found   ·    1 opt   ·    1 flat    13ms
13:47:22.499 | 🥚 /vercel/path0/.tamagui/css/apptabsdictionarywordconjugationtsx.css
13:47:22.503 | web  \|                     index   ·    1 found   ·    1 opt   ·    1 flat     4ms
13:47:22.503 | 🥚 /vercel/path0/.tamagui/css/apptabsdictionarywordindextsx.css
13:47:22.567 | web  \|                     index   ·    1 found   ·    1 opt   ·    0 flat    32ms
13:47:22.618 | web  \|                     index   ·    1 found   ·    1 opt   ·    1 flat     3ms
13:47:22.619 | 🥚 /vercel/path0/.tamagui/css/apptabsprofileindextsx.css
13:47:22.623 | web  \|                   support   ·    2 found   ·    1 opt   ·    1 flat     3ms
13:47:22.623 | 🥚 /vercel/path0/.tamagui/css/apptabssupporttsx.css
13:47:22.632 | web  \|                +not-found   ·    3 found   ·    1 opt   ·    3 flat     9ms
13:47:22.633 | 🥚 /vercel/path0/.tamagui/css/appnotfoundtsx.css
13:47:57.091 | Web Bundling failed 59961ms (node_modules/expo-router/entry.js)
13:47:57.092 |  
13:47:57.093 | Error: Unable to resolve module /vercel/path0/.tamagui/css/apptabsdictionarywordconjugationtsx.css from /vercel/path0/app/(tabs)/dictionary/[word]/conjugation.tsx:
13:47:57.093 |  
13:47:57.093 | None of these files exist:
13:47:57.093 | * .tamagui/css/apptabsdictionarywordconjugationtsx.css(.web.ts\|.ts\|.web.tsx\|.tsx\|.web.mjs\|.mjs\|.web.js\|.js\|.web.jsx\|.jsx\|.web.json\|.json\|.web.cjs\|.cjs\|.web.scss\|.scss\|.web.sass\|.sass\|.web.css\|.css\|.web.css\|.css)
13:47:57.093 | * .tamagui/css/apptabsdictionarywordconjugationtsx.css/index(.web.ts\|.ts\|.web.tsx\|.tsx\|.web.mjs\|.mjs\|.web.js\|.js\|.web.jsx\|.jsx\|.web.json\|.json\|.web.cjs\|.cjs\|.web.scss\|.scss\|.web.sass\|.sass\|.web.css\|.css\|.web.css\|.css)
13:47:57.094 | 9 \|   );
13:47:57.097 | 10 \| }
13:47:57.097 | > 11 \|
13:47:57.098 | \| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
13:47:57.099 | Error: Unable to resolve module /vercel/path0/.tamagui/css/apptabsdictionarywordconjugationtsx.css from /vercel/path0/app/(tabs)/dictionary/[word]/conjugation.tsx:
13:47:57.099 |  
13:47:57.099 | None of these files exist:
13:47:57.099 | * .tamagui/css/apptabsdictionarywordconjugationtsx.css(.web.ts\|.ts\|.web.tsx\|.tsx\|.web.mjs\|.mjs\|.web.js\|.js\|.web.jsx\|.jsx\|.web.json\|.json\|.web.cjs\|.cjs\|.web.scss\|.scss\|.web.sass\|.sass\|.web.css\|.css\|.web.css\|.css)
13:47:57.101 | * .tamagui/css/apptabsdictionarywordconjugationtsx.css/index(.web.ts\|.ts\|.web.tsx\|.tsx\|.web.mjs\|.mjs\|.web.js\|.js\|.web.jsx\|.jsx\|.web.json\|.json\|.web.cjs\|.cjs\|.web.scss\|.scss\|.web.sass\|.sass\|.web.css\|.css\|.web.css\|.css)
13:47:57.101 | 9 \|   );
13:47:57.102 | 10 \| }
13:47:57.102 | > 11 \|
13:47:57.103 | \| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
13:47:57.108 | at ModuleResolver.resolveDependency (/vercel/path0/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:127:15)
13:47:57.108 | at DependencyGraph.resolveDependency (/vercel/path0/node_modules/metro/src/node-haste/DependencyGraph.js:271:43)
13:47:57.108 | at /vercel/path0/node_modules/metro/src/lib/transformHelpers.js:176:21
13:47:57.108 | at resolveDependencies (/vercel/path0/node_modules/metro/src/DeltaBundler/buildSubgraph.js:56:25)
13:47:57.109 | at visit (/vercel/path0/node_modules/metro/src/DeltaBundler/buildSubgraph.js:107:30)
13:47:57.109 | at async Promise.all (index 2)
13:47:57.109 | at visit (/vercel/path0/node_modules/metro/src/DeltaBundler/buildSubgraph.js:116:5)
13:47:57.109 | at async Promise.all (index 0)
13:47:57.109 | at visit (/vercel/path0/node_modules/metro/src/DeltaBundler/buildSubgraph.js:116:5)
13:47:57.109 | at async Promise.all (index 1)
13:47:57.109 | at visit (/vercel/path0/node_modules/metro/src/DeltaBundler/buildSubgraph.js:116:5)
13:47:57.109 | at async Promise.all (index 1)
13:47:57.109 | at visit (/vercel/path0/node_modules/metro/src/DeltaBundler/buildSubgraph.js:116:5)
13:47:57.109 | at async Promise.all (index 0)
13:47:57.111 | at buildSubgraph (/vercel/path0/node_modules/metro/src/DeltaBundler/buildSubgraph.js:127:3)
13:47:57.111 | at Graph._buildDelta (/vercel/path0/node_modules/metro/src/DeltaBundler/Graph.js:249:22)
13:47:57.111 | at Graph.initialTraverseDependencies (/vercel/path0/node_modules/metro/src/DeltaBundler/Graph.js:227:19)
13:47:57.111 | at DeltaCalculator._getChangedDependencies (/vercel/path0/node_modules/metro/src/DeltaBundler/DeltaCalculator.js:221:25)
13:47:57.111 | at DeltaCalculator.getDelta (/vercel/path0/node_modules/metro/src/DeltaBundler/DeltaCalculator.js:111:16)
13:47:57.111 | at DeltaBundler.buildGraph (/vercel/path0/node_modules/metro/src/DeltaBundler.js:54:5)
13:47:57.111 | at IncrementalBundler.buildGraphForEntries (/vercel/path0/node_modules/metro/src/IncrementalBundler.js:66:19)
13:47:57.111 | at IncrementalBundler.buildGraph (/vercel/path0/node_modules/metro/src/IncrementalBundler.js:146:19)
13:47:57.111 | at forkMetroBuildAsync (/vercel/path0/node_modules/@expo/cli/src/export/fork-bundleAsync.ts:284:30)
13:47:57.112 | at buildAsync (/vercel/path0/node_modules/@expo/cli/src/export/fork-bundleAsync.ts:188:25)
13:47:57.112 | at async Promise.all (index 0)
13:47:57.112 | at bundleProductionMetroClientAsync (/vercel/path0/node_modules/@expo/cli/src/export/fork-bundleAsync.ts:205:12)
13:47:57.112 | at Object.createBundlesAsync (/vercel/path0/node_modules/@expo/cli/src/export/fork-bundleAsync.ts:82:19)
13:47:57.112 | at Object.exportAppAsync (/vercel/path0/node_modules/@expo/cli/src/export/exportApp.ts:86:19)
13:47:57.112 | at exportAsync (/vercel/path0/node_modules/@expo/cli/src/export/exportAsync.ts:18:3)
13:47:57.175 | Error: Command "expo export -p web" exited with 1

Expected Behavior

No response

Tamagui Version

1.89.15

Platform (Web, iOS, Android)

Web

Reproduction

https://github.com/iamursky/tamagui-expo-vercel

System Info

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 4
  • Comments: 36 (14 by maintainers)

Most upvoted comments

Returning a promise in a async function should already await it. Like I said it’s some mysterious timing issue due to watchpack or something. I can make the wait delay higher or configurable maybe. Or we are definitely doing something wrong.

I need to talk to someone working on metro. I have an idea of who to reach out. Will do that today b

The latest release I’ve added npx @tamagui/cli build which can pre-build a folder. Let me know if this works as a temporary measure. We are looking into a better fix this week.

Hi,

Same here with TamagUI ^1.94.4 for the project https://github.com/parti-renaissance/app-mobile

We reproduce 100% of the time the issue in docker for instance (using yarn) :

  • First npx expo export -p web lead to Error: Unable to resolve module....css .
  • Second npx expo export -p web lead to TypeError: Cannot read properties of undefined (reading 'length')
  • Third one is a success

So we build 3 time, ignoring first 2 errors, but this is not the best thing as we know. Execution of github action can be seen here in Compile web assets stage (please note that this CI/CD pipeline is currently under development)

We can commit the .tamagui directory, but we prefer not because it will PRs a little harder to read 😅.

I updated all of our tamagui components to 1.101.0 in our project and we’re getting

Error running command: Cannot read properties of undefined (reading ‘length’)

when running npx @tamagui/cli build

We see the .tamagui folder get created with only the tamagui-components.config.cjs and tamagui.config.cjs files.

When running the normal command, we’re getting a stack trace

/[brevity]/node_modules/@tamagui/simple-hash/src/index.ts:9
  const len = str.length
                  ^
TypeError: Cannot read properties of undefined (reading 'length')
    at simpleHash (/[brevity]/node_modules/@tamagui/simple-hash/src/index.ts:9:19)
    at createCSSVariable (/[brevity]/node_modules/@tamagui/web/src/createVariable.ts:111:16)
    at variableToCSS (/[brevity]/node_modules/@tamagui/web/src/helpers/registerCSSVariable.ts:10:63)
    at /[brevity]/node_modules/@tamagui/web/src/createTamagui.ts:129:29
    at createTamagui (/[brevity]/node_modules/@tamagui/web/src/createTamagui.ts:194:3)
    at loadTamagui (/[brevity]/node_modules/@tamagui/static/src/extractor/loadTamagui.ts:61:20)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at Object.load [as loadTamagui] (/[brevity]/node_modules/@tamagui/static/src/extractor/createExtractor.ts:137:29)

Am I missing something? Is there any more information I can provide?

did TAMAGUI_METRO_INLINE_CSS work?

Ok hear you guys clearly, seems like something has changed I don’t think on our side but maybe in one of the deps we use. I will investigate this this weekend.

Just chiming in here to echo that this is actively affecting our Expo 51 project as well, and we’re having to workaround it ATM by committing everything (which won’t be sustainable for very long).

Excited to see if a proper fix can be made in mainline soon; I anticipate we’ll have to try to ugly-hack around it ourselves within a week or two otherwise to keep our commit log / GitHub search index / etc. from being permanently crazy.

Thanks as always for the work you all are doing on this project!

I ran into this after upgrading to expo 50 and switching to metro completely following these guides:

Server runs fine locally (most likely because of the existing .tamagui dir).

As jmatsushita mentioned, I also committed .tamagui to have this step skipped and my deploy worked.