medusa
medusa copied to clipboard
Medusa store doesn't work for pnpm without hoisting
Bug report
Describe the bug
We have a preference for pnpm due to its improved performance. Installing packages with pnpm however does not work, unless if you create a .npmc with node-linker=hoisted
I'm not sure where this issue originates from, but having to resort to hoisting with pnpm gives a flat node modules like yarn, and removes the the improved performance
System information
Medusa version (including plugins): Medusa CLI version: 1.3.19 Node.js version: v18.16.0 Operating system: MacOS Ventura 13.4.1 (c) - ARM M1
Steps to reproduce the behavior
- Create app with medusa new (yarn is used to install the packages, would have preferred being able to use pnpm here as well but thats something for another issue/feature).
- remove node_modules and lockfile
- pnpm install
- pnpm run dev (or medusa dev)
Then you get a whole list of errors of missing dependencies:
store:dev: > cross-env ./node_modules/.bin/rimraf dist
store:dev:
store:dev: src/admin/components/onboarding-flow/orders/orders-list.tsx(3,33): error TS2307: Cannot find module 'medusa-react' or its corresponding type declarations.
store:dev: src/admin/components/onboarding-flow/orders/orders-list.tsx(4,42): error TS2307: Cannot find module 'medusa-react' or its corresponding type declarations.
store:dev: src/admin/components/onboarding-flow/orders/orders-list.tsx(5,41): error TS2307: Cannot find module 'medusa-react' or its corresponding type declarations.
store:dev: src/admin/components/onboarding-flow/orders/orders-list.tsx(6,33): error TS2307: Cannot find module 'medusa-react' or its corresponding type declarations.
store:dev: src/admin/components/onboarding-flow/orders/orders-list.tsx(7,27): error TS2307: Cannot find module 'medusa-react' or its corresponding type declarations.
store:dev: src/admin/components/onboarding-flow/products/product-detail.tsx(2,44): error TS2307: Cannot find module 'medusa-react' or its corresponding type declarations.
store:dev: src/admin/components/onboarding-flow/products/products-list.tsx(3,65): error TS2307: Cannot find module 'medusa-react' or its corresponding type declarations.
store:dev: src/admin/components/onboarding-flow/products/products-list.tsx(4,33): error TS2307: Cannot find module 'medusa-react' or its corresponding type declarations.
store:dev: src/admin/components/shared/accordion.tsx(1,37): error TS2307: Cannot find module '@radix-ui/react-accordion' or its corresponding type declarations.
store:dev: src/admin/components/shared/accordion.tsx(2,18): error TS2307: Cannot find module 'clsx' or its corresponding type declarations.
store:dev: src/admin/components/shared/badge.tsx(1,18): error TS2307: Cannot find module 'clsx' or its corresponding type declarations.
store:dev: src/admin/components/shared/button.tsx(1,18): error TS2307: Cannot find module 'clsx' or its corresponding type declarations.
store:dev: src/admin/components/shared/code-snippets.tsx(2,18): error TS2307: Cannot find module 'clsx' or its corresponding type declarations.
store:dev: src/admin/components/shared/code-snippets.tsx(3,18): error TS2307: Cannot find module 'copy-to-clipboard' or its corresponding type declarations.
store:dev: src/admin/components/shared/icon-badge.tsx(1,18): error TS2307: Cannot find module 'clsx' or its corresponding type declarations.
store:dev: src/admin/components/shared/spinner.tsx(1,18): error TS2307: Cannot find module 'clsx' or its corresponding type declarations.
store:dev: src/admin/widgets/onboarding-flow/onboarding-flow.tsx(2,57): error TS2307: Cannot find module 'medusa-react' or its corresponding type declarations.
store:dev: src/admin/widgets/onboarding-flow/onboarding-flow.tsx(4,29): error TS2307: Cannot find module 'react-router-dom' or its corresponding type declarations.
store:dev: src/api/index.ts(5,31): error TS2307: Cannot find module 'medusa-core-utils' or its corresponding type declarations.
store:dev: src/api/routes/admin/onboarding/index.ts(1,29): error TS2307: Cannot find module '@medusajs/utils' or its corresponding type declarations.
store:dev: src/migrations/1685715079776-CreateOnboarding.ts(1,34): error TS2307: Cannot find module '@medusajs/utils' or its corresponding type declarations.
store:dev: npm ERR! Lifecycle script `build:server` failed with error:
store:dev: npm ERR! Error: command failed
store:dev: npm ERR! in workspace: [email protected]
store:dev: npm ERR! at location: /Users/rick/Documents/projects/openchrono/apps/store
store:dev: ELIFECYCLE Command failed with exit code 1.
store:dev: command finished with error, but continuing...
store#dev: command (/Users/rick/Documents/projects/openchrono/apps/store) pnpm run dev exited (1)
Expected behavior
App starts like normal with all dependencies
A clear and concise description of what you expected to happen
Additional context
Hoisting is fine for now but might have some time to work on this issue at a later time. Would be eager to hear what's already known on this
I think the problem lies in how Yarn was configured: https://github.com/medusajs/medusa/blob/b5bc33a9d7b94886189819b34b7d934e27a0d196/.yarnrc.yml#L7
To fix this issue, it's necessary to remove that line, but doing so can potentially cause a lot of other issues as well.
Moving to a pnpm workspace is another option, but it will require a significant amount of effort.