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:

qq20171228-164317 2x

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 5
  • Comments: 49 (5 by maintainers)

Most upvoted comments

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 a npm uninstall -g exp followed by yarn global add exp

and 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.

  • Delete all node_modules and reinstall everything (npm install). Let me know if this solves your problems.

This appears to be something very new, I haven’t seen a problem like that before. Started out of nowhere, no helpful logs… image

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/MyExpoProject

I moved my project to a new path: /Users/pat/projects/MyExpoProject restarted 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 exp followed by yarn 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 install

then try with expo start

then 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

npm start – – reset-cache

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:

error: bundling failed: Error: While trying to resolve module `react-native-vector-icons` from file `/Users/dj/Desktop/learn/react-native/crm/src/components/PersonItem.js`, the package `/Users/dj/Desktop/learn/react-native/crm/node_modules/react-native/local-cli/core/__fixtures__/files/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`/Users/dj/Desktop/learn/react-native/crm/node_modules/react-native/local-cli/core/__fixtures__/files/index.js`. Indeed, none of these files exist:

  * `/Users/dj/Desktop/learn/react-native/crm/node_modules/react-native/local-cli/core/__fixtures__/files/index.js(.native||.android.js|.native.js|.js|.android.json|.native.json|.json)`
  * `/Users/dj/Desktop/learn/react-native/crm/node_modules/react-native/local-cli/core/__fixtures__/files/index.js/index(.native||.android.js|.native.js|.js|.android.json|.native.json|.json)`
    at ResolutionRequest.resolveDependency (/Users/dj/Desktop/learn/react-native/crm/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:108:15)
    at DependencyGraph.resolveDependency (/Users/dj/Desktop/learn/react-native/crm/node_modules/metro/src/node-haste/DependencyGraph.js:269:4352)
    at /Users/dj/Desktop/learn/react-native/crm/node_modules/metro/src/DeltaBundler/traverseDependencies.js:201:36
    at Generator.next (<anonymous>)
    at step (/Users/dj/Desktop/learn/react-native/crm/node_modules/metro/src/DeltaBundler/traverseDependencies.js:256:306)
    at /Users/dj/Desktop/learn/react-native/crm/node_modules/metro/src/DeltaBundler/traverseDependencies.js:256:536
    at new Promise (<anonymous>)
    at /Users/dj/Desktop/learn/react-native/crm/node_modules/metro/src/DeltaBundler/traverseDependencies.js:256:217
    at addDependency (/Users/dj/Desktop/learn/react-native/crm/node_modules/metro/src/DeltaBundler/traverseDependencies.js:256:92)
    at /Users/dj/Desktop/learn/react-native/crm/node_modules/metro/src/DeltaBundler/traverseDependencies.js:237:9

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 start in the terminal just now and found error as follows. it’s caused by React%20Native (React Native)

274918dc-ce21-433f-82e0-8d2b8d64fa8c