expo: Web publishing JS files renders 404 - also assets path are not correct
Summary
Created expo router app using npx create-expo-app@latest --template tabs@49. After web publishing using npx expo export -p web, running it locally using npx serve dist returns 404 when access the expo router entry js file. I tried without router, then i am not seeing this issue.
Please help. Thank you.
HTTP 8/22/2023 7:26:49 PM ::1 GET / HTTP 8/22/2023 7:26:49 PM ::1 Returned 304 in 1 ms HTTP 8/22/2023 7:26:49 PM ::1 GET /_expo/static/js/web/node_modules%5Cexpo-router%5Centry-4d3ee3ac1dee2ccae600db09a0f66c57.js HTTP 8/22/2023 7:26:49 PM ::1 Returned 404 in 3 ms
What platform(s) does this occur on?
Web
SDK Version
49
Environment
expo-env-info 1.0.5 environment info: System: OS: Windows 10 10.0.19044 Binaries: Node: 16.14.0 - C:\Program Files\nodejs\node.EXE npm: 9.8.1 - C:\Program Files\nodejs\npm.CMD IDEs: Android Studio: AI-222.4459.24.2221.10121639 npmPackages: expo: ~49.0.8 => 49.0.8 react: 18.2.0 => 18.2.0 react-dom: 18.2.0 => 18.2.0 react-native: 0.72.4 => 0.72.4 react-native-web: ~0.19.6 => 0.19.7 Expo Workflow: managed
Minimal reproducible example
About this issue
- Original URL
- State: closed
- Created 10 months ago
- Reactions: 4
- Comments: 19 (2 by maintainers)
Commits related to this issue
- fix(metro-config): Normalize paths on Windows machines. (#24382) # Why - fix https://github.com/expo/expo/issues/24073 # Test Plan I don't have a windows machine so I'm just guessing that th... — committed to expo/expo by EvanBacon 10 months ago
- fix(metro-config): Normalize paths on Windows machines. (#24382) # Why - fix https://github.com/expo/expo/issues/24073 # Test Plan I don't have a windows machine so I'm just guessing that th... — committed to expo/expo by EvanBacon 10 months ago
Still seeing some issues on Windows which I think are associated with this. All these errors are happening when using expo 49 with expo-router v2 with app.json expo.web.output = ‘static’. It all works perfectly fine with output = ‘single’, or without expo-router.
npx expo export -p webgenerates a javascript bundle with the following path:dist\_expo\static\js\web\node_modules%5Cexpo-router%5Centry-5656cb2cd48dddfadacde359b7eaec75.jsNote the
%5Cin the path. This results in a 404 when serving the page.In the file name, replacing the %5C with backslashes makes it work, even without changing the script src in the generated html files.
Also fails when running
npx expo start --web --no-dev, except the error message isRefused to execute script from 'http://localhost:8081/_expo/static/js/web/node_modules%5Cexpo-router%5Centry-e62ad1b0c047c48d8822a4cab05e3eeb.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.. Navigating to the script results in a 404.the path should be https://yourdomainname.com/feapp/assets/assets/fonts/SpaceMono-Regular.ttf?platform=web&hash=49a79d66bdea2debf1832bf4d7aca127 not like below
Looks like
npx expo export -p webis not building path correctly for expo router entry js path. For example, the path _expo/static/js/web/node_modules%5Cexpo-router%5Centry-4d3ee3ac1dee2ccae600db09a0f66c57.js is not correct if i changed to _expo/static/js/web/node_modules/expo-router/entry-4d3ee3ac1dee2ccae600db09a0f66c57.js, then i am able to see the entry js file served correctly on browser.Getting with
npx expo export -p webalso a duplicated assets folder inside dist.I am not sure how far is this issue related to the previous one.