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.

With symlinked packages: Error: Unable to resolve module `@scope/ui` from `/some/path.js`: Module `@scope/ui` does not exist in the Haste module map

See original GitHub issue

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

Bug

What is the current behavior?

I have a lerna monorepo where i decided to scope the packages inside. When I run lerna link --force-local (which essentially symlinks my local packages inside of others if they are mentioned in the package.json) my React Native app at some point will have the following directory in it: ./node_modules/@scope/ui and ui is the symlinked directory.

If I now start the metro bundler and run the app, it will throw following error:

error: bundling failed: Error: Unable to resolve module `@scope/ui` from `/Projects/myMainLerna/packages/myRnApp/index.js`: Module `@scope/ui` does not exist in the Haste module map

I have seen all the other issues around this like https://github.com/facebook/react-native/issues/4968 and https://github.com/facebook/metro/issues/241 and many others, but this is something unrelated to the causes in the other issues.

How do I know it’s a problem with symlinked packages? I simply threw a real copy of my package into my ./node_modules/@scope/ui and it started working. It might be though that symlinked packages, if not put into a scope directory, work - I don’t know because I didn’t try that one.

How to reproduce and a minimal repository on GitHub

https://github.com/mxmzb/MetroLinkedHasteExample and follow the README instructions

What is the expected behavior?

App finds and uses the package.

Please provide your exact Metro configuration and mention your Metro, node, yarn/npm version and operating system.

Note: it doesn’t seem to matter if I use yarn or npm.

Metro configuration: As it comes with React Native node: 8.12.0 yarn: 1.10.1 npm: 6.4.1 All on macOS

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:29
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
nickaroracommented, Oct 11, 2018

We are dealing with a similar issue using yarn workspaces. Attempts to work around it using extraNodeModules were unsuccessful. Would appreciate if the maintainers could offer recommendations

3reactions
MehdiDonkcommented, Nov 21, 2019

Hi, You can try WML. https://www.npmjs.com/package/wml

What it does:

replaces npm link with something that actually works!

It worked for me ! Cheers

Read more comments on GitHub >

github_iconTop Results From Across the Web

reactjs - Unable to resolve module...does not exist in the haste ...
But since I started the new project, after adding custom modules in the project I have this error message. In this case I...
Read more >
Symlinked `node_modules` structure - PNPM
This article only describes how pnpm's node_modules are structured when there are no packages with peer dependencies. For the more complex scenario of ......
Read more >
[Solved]-Unable to resolve module...does not exist in the haste ...
Coding example for the question Unable to resolve module...does not exist in the haste module map-React Native.
Read more >
Symlink Tutorial in Linux – How to Create and Remove a ...
A symlink (also called a symbolic link) is a type of file in Linux that points to another file or a folder on...
Read more >
Module fs does not exist in the Haste module map
bundling failed: Error: Unable to resolve module `_wrapObjectFreezeAndFriends` from ` /node_modules/react-native/Libraries/Core/polyfillES6Collections.js`: ...
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