i’ve ran into some issues running my expo project, and i’m quite new to app development (with react native / expo, and as a whole) so i apologise if this is something trivial that i missed out on, but i’ve been completely unable to fix this for a few days now so i felt this subreddit was my best bet.
when i run my expo app, i run into a long chain of
Error: ENOENT: no such file or directory, open (insert file name)
the files in that chain are:
- node_modules/@expo/cli/src/start/server/metro/MetroBundlerDevServer.ts (6 times)
- node_modules/@expo/cli/src/start/server/metro/createServerRouteMiddleware.ts
- node_modules/@expo/server/src/index.ts
- node_modules/@expo/server/src/vendor/http.ts
at the end of that long chain, i get this:
Metro error: Serializer did not return expected format. The project copy of `expo/metro-config` may be out of date. Error: Unexpected token 'v', "var __BUND"... is not valid JSON
here’s some information about my project:
- expo version 6.3.10
- node version 20.15.1
here’s my metro.config.js
file:
const { getDefaultConfig, mergeConfig } = require("@react-native/metro-config");
const defaultConfig = getDefaultConfig(__dirname);
const { resolver: { sourceExts, assetExts } } = defaultConfig;
const config = {
...defaultConfig,
transformer: {
babelTransformerPath: require.resolve('react-native-svg-transformer'),
assetPlugins: ['expo-asset/tools/hashAssetFiles'],
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: false,
},
}),
},
resolver: {
assetExts: assetExts.filter(ext => ext !== 'svg'),
sourceExts: [...sourceExts, 'svg'],
},
};
module.exports = mergeConfig(defaultConfig, config);
if it helps, here’s my repo.
i genuinely have no idea what is wrong with my code and what i should do to fix it. here are the steps i have taken to try and stop this error from showing up again:
- looked up the “Serializer did not return expected format.” and only found one post with that exact wording in it, and the error in that post did not have the same “invalid JSON” as mine (nevertheless, i followed the instructions i found in the comments which did nothing)
- cleared node_modules and reran npm install
- checked all the files in the chain of ENOENTs (none of them exist, and i have no idea what to do about that either)
- updated all libraries
- tried to find any files with the text “var __BUND” and found nothing, so i have no idea where that is from
- cleared cache on every run