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 issueDo 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:
- Created 5 years ago
- Reactions:29
- Comments:8 (2 by maintainers)
Top GitHub Comments
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 recommendationsHi, You can try WML. https://www.npmjs.com/package/wml
What it does:
It worked for me ! Cheers