question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Failed building JavaScript bundle error when application starts

See original GitHub issue

Description

When I first create a create-react-native-app project and scan qr on my phone with expo, It threw javascipt bundling error instead of starting.

Expected Behavior

I expect to see my lovely first working react-native application

Observed Behavior

333333333333333

222222222222222222222

11:21:59: Failed building JavaScript bundle
11:21:59: Error: Expected path `C:\Users\Naim\Documents\projects\nativedeneme\node_modules\metro-bundler\src\Resolver\polyfills\prelude_dev.js` to be relative to one of the project roots
11:21:59:     at toLocalPath (C:\Users\Naim\Documents\projects\nativedeneme\node_modules\metro-bundler\src\node-haste\lib\toLocalPath.js:33:9)
11:21:59:     at ModuleCache.createPolyfill (C:\Users\Naim\Documents\projects\nativedeneme\node_modules\metro-bundler\src\node-haste\ModuleCache.js:166:18)
11:21:59:     at DependencyGraph.createPolyfill (C:\Users\Naim\Documents\projects\nativedeneme\node_modules\metro-bundler\src\node-haste\DependencyGraph.js:312:30)
11:21:59:     at map.moduleName (C:\Users\Naim\Documents\projects\nativedeneme\node_modules\metro-bundler\src\Resolver\index.js:150:38)
11:21:59:     at Array.map (native)
11:21:59:     at Resolver.getModuleSystemDependencies (C:\Users\Naim\Documents\projects\nativedeneme\node_modules\metro-bundler\src\Resolver\index.js:150:5)
11:21:59:     at _resolverPromise.then.resolver (C:\Users\Naim\Documents\projects\nativedeneme\node_modules\metro-bundler\src\Bundler\index.js:273:31)
11:21:59:     at <anonymous>
11:21:59:     at process._tickCallback (internal/process/next_tick.js:188:7)

Environment

  • npm ls react-native-scripts: react-native-scripts@1.5.0
  • npm ls react-native: react-native@0.48.4
  • npm ls expo: expo@21.0.2
  • node -v: v8.2.1
  • npm -v: 4.6.1
  • yarn --version: ‘yarn’ is not recognized as an internal or external command
  • watchman version: Please specify a target and action
  1. Operating system: Windows 10 Pro 1703
  2. Phone/emulator/simulator & version: Galaxy J7 (2016) SM-J710FQ Android 7.0 (Expo 1.20.0) (Nexus_5X_API_25_2 Android 7.1.1 and Nexus_5X_API_23 Android 6.0 emulators in Android Studio gave same error)

Reproducible Demo

npm install -g create-react-native-app create-react-native-app nativedeneme cd nativedeneme npm start Scan QR code with Expo on the phone

node_modules\metro-bundler\src\node-haste\lib\toLocalPath.js: (this dude is unhappy I think)

'use strict';var _require =

require('path');const relative = _require.relative;

// FIXME: This function has the shortcoming of potentially returning identical
// paths for two files in different roots.
function toLocalPath(
roots,
absolutePath)
{
  for (let i = 0; i < roots.length; i++) {
    const localPath = relative(roots[i], absolutePath);
    if (localPath[0] !== '.') {
      return localPath;
    }
  }

  throw new Error(
  `Expected path \`${absolutePath}\` to be relative to one of the project roots`);

}

module.exports = toLocalPath;

Installing yarn and using it instead of npm for everything gave same error.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
MauroNavaLuevanoscommented, Feb 15, 2018

i only stop the bundle with ctrl+c (on windows) and again start the project, npm start and the app works fine without errors

1reaction
nb256commented, Nov 22, 2017

//throw new Error( //Expected path \${absolutePath}` to be relative to one of the project roots`);

Ignoring these lines like this fixed my issue, I think they are not necessary for me right now 😄

edit: DO NOT USE THIS, JUST UPDATE YOUR EXPO APP AND CREATE CREATE-REACT-NATIVE-APP TO C://

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native Expo Failed building JavaScript bundle
I get the following error message in the logs of exp start when I try to launch the simulator on Xcode: Failed building...
Read more >
Failed building JavaScript bundle error when application starts
When I first create a create-react-native-app project and scan qr on my phone with expo, It threw javascipt bundling error instead of starting....
Read more >
Building JavaScript bundle: error - Expo Development Tools
I'm getting this error on my first project. i have not added any library ... Expo Dev browser window Building JavaScript bundle: error...
Read more >
Addressing common errors in React Native - LogRocket Blog
Solution 1: Package the bundle correctly. All of your app's JavaScript is bundled into the index.android.bundle file.
Read more >
Troubleshooting - React Native
You will also need to update your applications to load the JavaScript bundle from the new port. If running on device from Xcode,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found