medusajs / medusa

The world's most flexible commerce platform.
https://medusajs.com
MIT License
26.25k stars 2.67k forks source link

Medusa monorepo with turborepo doesn't start because of `@medusajs/admin` #5120

Open durdenx opened 1 year ago

durdenx commented 1 year ago

Bug report

Describe the bug

I'm encountering a bug when trying to integrate MedusaJS into a monorepo with TurboRepo. When attempting to run MedusaJS in this context, I'm receiving the following error:

[@medusajs/admin] resolve 'swc-loader' in '/Users/user/Documents/web/medusa-turborepo/apps/medusa'

This issue seems to be specific to @medusajs/admin v7, as it was working with the v6 in a similar setup.

You can see a reproduction there : https://github.com/durdenx/medusa-turborepo.

System information

Steps to reproduce the behavior

  1. Clone the repository: git clone https://github.com/durdenx/medusa-turborepo
  2. Navigate to the project directory: cd medusa-turborepo
  3. Setup .env (rename .env.template to .env)
  4. Install database: docker-compose up -d
  5. Install dependencies: pnpm install
  6. Try to run : pnpm dev

Expected behavior

I expected MedusaJS to run successfully within the TurboRepo monorepo environment.

Additional context

Related to #4532 and #5544

Any help or suggestions to resolve this issue would be greatly appreciated.

Thank you in advance for your assistance!

abdokouta commented 1 year ago

Same issue for Nx monorepos

aliameur commented 11 months ago

Any update on this?

olivermrbl commented 11 months ago

@aliameur, are you experiencing the issue using turborepo?

olivermrbl commented 11 months ago

@durdenx, I am unable to reproduce your issue following the steps (with out docker, though). Could I get you to try again, so I can be sure the issue still exist for turborepo setups?

durdenx commented 11 months ago

@olivermrbl Yes, I temporarily set shamefully-hoist = true in the .npmrc file as a workaround. Just remove this setting to get back to the initial issue.

olivermrbl commented 11 months ago

@durdenx, any chance I could get you to update the repo (or a branch in the repo) to the reproducible state? I would like to be sure we have 1:1 setups.

durdenx commented 11 months ago

@olivermrbl, I've updated the repository. Please make sure to run pnpm clean and pnpm install from the root to see the error.

aliameur commented 11 months ago

@olivermrbl , no I am using a nx monorepo. It seems that @meduajs/admin needs its depedencies in the same directory, and when you hack around it with nx, you start getting getting a load of dependency issues from the .cache folder.

olivermrbl commented 10 months ago

Can I get you to try the following snapshots:

@medusajs/medusa@1.19.1-snapshot-20240108132634
@medusajs/medusa-cli@1.3.23-snapshot-20240108132634

Any or all of you.

durdenx commented 10 months ago

@olivermrbl It's not working. After updating, I still encounter the same error: Module not found: Error: Can't resolve 'swc-loader'

olivermrbl commented 10 months ago

Sorry, I should have added that my attempt will not solve the issue with the swc-loader, only the issues related to babel and medusa executables. I realise this is what was initially reported – I apologise for the confusion my comment may have caused.

If you install the swc-loader package (and the other failing one) separately in your project, as mentioned here, you should be able to resolve your issue.

This is not ideal. However, the issue will be permanently eliminated as we update our admin at the end of this month.

durdenx commented 10 months ago

Even when I install swc-loader, I then need to install all the admin dependencies (react, radix, etc.), and I encounter the following error: [@medusajs/admin] Could not find the admin UI build files. Please run "medusa-admin build" or enable "autoRebuild" in the plugin options to build the admin UI.

For now, adding shamefully-hoist = true in .npmrc is working well for me. I will wait for you to update Medusa Admin at the end of the month.

facundocapua commented 9 months ago

For is happening too, the workaround suggested by @durdenx works for me

buffcode commented 8 months ago

Any updates on this? In which version is / was this expected to be fixed?

We have a monorepo and shamefully-hoist = true only works globally within the repo and cannot be restricted to the medusa part only.