Skip to content

Yarn workspaces expo amplify, Error: resolveDependencies: Found duplicate dependency key 'undefined' in #857

@alifa20

Description

@alifa20

Do you want to request a feature or report a bug?
bug

What is the current behaviour?
The app shows red box related to metro
1

If the current behaviour is a bug, please provide the steps to reproduce and a minimal repository on GitHub that we can yarn install and yarn test.
I have setup Yarn workspaces mono repo with expo apps in /apps folder.
I also have amplify in the /packages folder.
By nature when I do amplify pull it gets an exact copy of what is up in AWS and hence I'll end up package.json with same name throughout the code base. Yarn workspace is not happy with multiple package.json files with the same name field.

I am using the following code (blacklistRE) to ignore unwanted source code to be considered in metro

const { getDefaultConfig } = require("expo/metro-config");
const path = require("path");
const exclusionList = require("metro-config/src/defaults/exclusionList");

const workspaceRoot = path.resolve(__dirname, "../..");
const projectRoot = __dirname;
const config = getDefaultConfig(projectRoot);
config.watchFolders = [workspaceRoot];
config.resolver.nodeModulesPaths = [
  path.resolve(projectRoot, "node_modules"),
  path.resolve(workspaceRoot, "node_modules"),
];

module.exports = {
  ...config,
  resolver: {
    ...config.resolver,
    blacklistRE: exclusionList([/amplify\/#current-cloud-backend\/.*/]),
  },
};

The code works just fine with "metro-config": "0.71.3" but when I upgrade to "metro-config": "0.72.0" I get the error as attached.

iOS Bundling failed 65ms
error: Error: resolveDependencies: Found duplicate dependency key 'undefined'

The command I am running is:
yarn workspace MyApp expo run:ios

Since there's not much doc around mono repos and metro configs I thought I share my findings and in case that's not a bug will be great if you guys can let me know what needs to be changed for the new version to work.

What is the expected behavior?
No error

Please provide your exact Metro configuration and mention your Metro, node, yarn/npm version and operating system.
OS: MacOs Montery
npm: 8.13.2
yarn: 1.22.19
"metro-config": "0.72.0"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions