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.

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

See original GitHub issue

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”

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:4
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
Aleksandriukascommented, Oct 2, 2022

In my case there was an issue with 2 versions of metro. I have found it by running npm ls metro:

Frame 67

So, removing the duplicated one resolved the issue.

3reactions
esWeborgcommented, Oct 13, 2022

The case is closed for me but only after deleting the library that contained a peerDependencies entry for metro-config v0.58 AND any mention of metro in my package.json (I had one, but removing that was not enough) Luckily I had a workaround for UI-kittens at https://akveo.github.io/react-native-ui-kitten/docs/design-system/customize-mapping#merge-mappings

I want to highlight that the metro dependency was in peerDependencies and I did run npm install with --legacy-peer-deps that should not create duplicates. I am going to blame the cache even if I spent hours clearing it all over the place.

Thanks again @robhogan the info you provided led me to the only possible conclusions: duplicates are not allowed and that’s it. I then spent time finding and killing them all (note that npm ls metro was a bit misleading when duplicates in peerDependencies were set to same version).

On a final note I’d like to share a 1liner npm script I used a lot in fixing this issue. Hope it helps others:

"scripts":
    ...
    "cache:clear": "watchman watch-del-all && rm package-lock.json && rm -rf node_modules && npm install --legacy-peer-deps && rm -rf /tmp/metro-* && npm run start -- --reset-cache"
Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: resolveDependencies: Found duplicate dependency ...
How do I debug this error: `error: Error: resolveDependencies: Found duplicate dependency key 'undefined' in <local path to metro bundler>` - RN ...
Read more >
facebook Code Example - Code Grepper
Error : Could not find "stylelint-config-standard". Do you need a `configBasedir`? ... Where are Docker volumes located when running WSL using Docker Desktop?...
Read more >
Index of /groups/npm-public
aws-amplify/, Tue Nov 08 16:01:10 CST 2022 ... babel-plugin-transform-es2015-duplicate-keys/ ... find-yarn-workspace-root/, Tue Mar 22 17:21:06 CST 2022.
Read more >
notebookffad25d0e2 - Kaggle
Explore and run machine learning code with Kaggle Notebooks | Using data from 60k Stack Overflow Questions with Quality Rating.
Read more >
sitemap-posts-1.xml - DEV Community ‍ ‍
... https://dev.to/jdoud1993/my-journey-using-find-to-return-keys-and-values-in- ... /setting-up-react-native-monorepo-with-yarn-workspaces-4kj0 2022-10-14 ...
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