metro: Metro bundler has encountered an internal error
When I run yarn start in the terminal and use Expo App to open my RN Project in iPhone, an error appears as follows:
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 5
- Comments: 49 (5 by maintainers)
easiest fix for me is killall node -9
Fam, I fixed my issue and like most of them, it’s completely my fault. I was refactoring and deleted some files without cleaning up some imports of the deleted files. The only way I found this was to add a console.log in metro (node_modules/metro/src/lib/formatBundlingError.js).
function formatBundlingError(error) { console.log(error); }Over on the Expo thread I opened, Brent helpfully recommended using yarn because npm5 apparently still has bugs.
In my case, even though I don’t recall using npm to install
exp, I nevertheless did anpm uninstall -g expfollowed byyarn global add expand I’m back in business. If you get a chance to try this, please post back if it worked for you.
Hope it helps!
I had the same issue, npm start – – reset-cache solved it, if it says cant run on port **** kill thoose process and reset again
On my side this error was caused by incompatible Expo <–> React-native versions (After upgrading expo) and it is solved now.
Here are the compatibilities: https://docs.expo.io/versions/latest/sdk/index.html -I replaced (e.g) the version of sdkVersion": “24.0.0” on app.json and expo “24.0.0” and react-native 0.51.0 (exact version)on package.json.
This appears to be something very new, I haven’t seen a problem like that before. Started out of nowhere, no helpful logs…
I just made a curious discovery. I had a plus character + in the absolute path to my project folder, e.g.
/Users/pat/projects/+ReactNative/MyExpoProjectI moved my project to a new path:
/Users/pat/projects/MyExpoProjectrestarted everything, and we’re off to the races.React Native doesn’t work with NodeJS 9 and new version of NPM You have to downgrade your NodeJS version or you can use NVM to set different node version for each terminal: https://github.com/creationix/nvm
Downgrade your node version to: 8.9 and your NPM version to: 4.6.1
after that remove your node_modules directory and run npm install again
@onpaws Thanks for investigating this problem. I have tried to
npm uninstall -g expfollowed byyarn global add exp, but it also doesn’t work for me. I think I’d go crazy!😭Ok so I was having the same issue but I just restarted my IDE, command line and ran the app again it worked fine.
I had huge refactoring today and got stuck for hours with dangling imports all over the place, but thanks to @GentryRiggen I managed to fix them all.
Remove Node module.
rm -rf node_modules/install again
npm installthen try with
expo startthen you will see the comming screen with
INFO : 12:37 Starting Metro Bundle on port 19001.
INFO : 12:37 Metro Bundler ready.
INFO : 12:37 Tunnel ready.
then run with your device.
npm installing modules without restarting expo XDE was the culprit for me, hope this helps
also, if you’re reading this; you are loved and don’t let anybody tell you otherwise ❤️
remove all files from C:\Users<your pc name>\AppData\Local\Temp
Thanks a lot…it works
Just in case anyone else finds themselves here, my solution (after several hours) to this exact error prompt was from VSCode sneakily importing:
import { Platform } from '../../node_modules/@types/react-native';at the top of one file amongst other imports. When it should obviously be:import { Platform } from 'react-native';I got the same error and when I checked my error log this is the error:
Its like its due to react-native-vector-icons package in my case. when I stop using the package, the error goes away. The error might be attached to some packages I’m not using expo
@onpaws I tried to create a new project in the path which doesn’t has non-alphanumeric character, it finally worked! lol
In my old project, there is non-alphanumeric characters in its absolute path. I ran
yarn startin the terminal just now and found error as follows. it’s caused byReact%20Native (React Native)!