Failed building JavaScript bundle. Cannot read property 'reduce' of undefined on react native module traverseDependencies.js

Viewed 1753

**Hi, I don't know what happen here, it's something release with a dependence, It's a code that I didn't write, it's a bundle and I use expo to run my code but, can't open my app because that error please help!! it's for a college project **

function resolveDependencies(parentPath, dependencies, options) {
  const resolve = (parentPath, result) => {
    const relativePath = result.name;

    try {
      return [
        relativePath,
        {
          absolutePath: options.resolve(parentPath, relativePath),
       data: result
        }
      ];
    } catch (error) {

Ignore unavailable optional dependencies. They are guarded with a try-catch block and will be handled during runtime.

if (result.data.isOptional !== true) {
           throw error;
         }
        }

       return undefined;
     };

     const resolved = dependencies.reduce((list, result) => {
       const resolvedPath = resolve(parentPath, result);

    if (resolvedPath) {
      list.push(resolvedPath);
    }

        return list;
      }, []);
  return new Map(resolved);
}
  • Re-traverse the dependency graph in DFS order to reorder the modules and
  • guarantee the same order between runs. This method mutates the passed graph.
3 Answers

I had the same issue on the latest expo-cli 4.8.1. For me helped following steps

  • downgrade from 4.8.1 -> 4.7.3 npm install -g expo-cli@~4.7.3
  • clear npm cache by executing npm cache clean --force
  • clear local user cache by deleting everything in C:\Users<user>\AppData\Local\Temp folder.

After these steps, it is working again

I had this issue when running expo start --dev-client on expo-cli version 4.12.1.

I solved it by adding the --clear flag (which clears the Metro bundler cache)

Deleting the system cache Temp folder content will work, When I face the same issue this solution help me to solve the problem

Related