-
-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Cannot find module" in yarn monorepo setup #472
Comments
Hi @epicbytes can you share the repository? |
https://github.com/epicbytes/sample-bug This is a monorepo recreated from scratch. |
I tried the example in StackBlitz and it works when adding a default value on this line https://github.com/epicbytes/sample-bug/blob/main/apps/web/src/pages/index.tsx#L17 -const locale = context.locale as Locales;
+const locale = context.locale as Locales || baseLocale; |
Unfortunately, this does not solve the problem, the error, as I understand it, is that the module does not find itself in the node_modules folder, which is located next to the application, because turborepo has its own shared directory at the root level of the monorepository. at the same time, typesafe tries to write exactly in node_modules next to the project, but does not see its code in it. The problem arises precisely in the fact that the module is confused among the directories. |
I was now finally able to reproduce your issue. Workaround for now: setting the |
I have found this issue. It seems the issue is the "hoisting" of packages in - "workspaces": [
- "apps/*",
- "packages/*"
- ],
+ "workspaces": {
+ "packages": [
+ "apps/*",
+ "packages/*"
+ ],
+ "nohoist": [
+ "**/typesafe-i18n",
+ "**/typesafe-i18n/**"
+ ]
+ }, |
Thanks, now it works as it should, it would be great to describe it in the documentation. |
I'll add a section to the FAQs. edit: added |
@ivanhofer I found the same issue happens on Nx monorepo. Is there anyone have solution? |
Version
5.14.0
Describe the bug
Hi! I ran into a problem when using turborepo, if the module is added to one application, then everything works as it should. But when added to the second, the module starts to give an error when both are started.
Applications are written in NextJS.
Both times the module is connected and initialized according to the instructions.
Reproduction
install module
auto setup module
connected this to one more application in turborepo
Logs
Config
Additional information
No response
The text was updated successfully, but these errors were encountered: