medusajs / nextjs-starter-medusa

A performant frontend ecommerce starter template with Next.js 14 and Medusa.
https://next.medusajs.com/
MIT License
1.55k stars 418 forks source link

App won't build with yarn build #279

Open undercontr opened 5 months ago

undercontr commented 5 months ago

Hello, I cloned the repo and installed the dependencies with yarn package. But when I want to build the next app with yarn build, below error appears,

PS D:\test\nextjs-starter-medusa> yarn build
next.config.js {}
   ▲ Next.js 14.0.4
   - Environments: .env.local

 ✓ Creating an optimized production build
 ✓ Compiled successfully
   Linting and checking validity of types  ...Failed to compile.

./src/app/[countryCode]/(checkout)/checkout/page.tsx:23:44
Type error: Parameter 'cart' implicitly has an 'any' type.

  21 |   }
  22 |
> 23 |   const cart = await getCart(cartId).then((cart) => cart)
     |                                            ^
  24 |
  25 |   if (cart?.items.length) {
  26 |     const enrichedItems = await enrichLineItems(cart?.items, cart?.region_id)
PS D:\test\nextjs-starter-medusa>

Does anybody bump this kind of build issues before on a clean cloned repo?

I am using

undercontr commented 5 months ago

To update here, it only works with yarn classic v1.22.19 not with yarn v3, even with nodeLinker, it does not calculate to exclude server components and sees them as a usual components. Same thing happens with pnpm v8 too. I think the issue here is yarn.lock file maybe does not supported by yarn v3?

LXBUGR commented 5 months ago

Hello, i also get this issue and i am using yarn classic v1.22.19

yarn --version 1.22.19

yarn build
yarn run v1.22.19 $ next build next.config.js {} ⚠ Invalid next.config.js options detected: ⚠ Invalid input at "env.FEATURE_SEARCH_ENABLED" ⚠ Expected string, received boolean at "env.FEATURE_SEARCH_ENABLED" ⚠ Expected undefined, received boolean at "env.FEATURE_SEARCH_ENABLED" ⚠ See more info here: https://nextjs.org/docs/messages/invalid-next-config ▲ Next.js 14.1.0

Creating an optimized production build ... next.config.js {} next.config.js {} Compiler edge-server unexpectedly exited with code: null and signal: SIGTERM next.config.js {} ✓ Compiled successfully Linting and checking validity of types ...Failed to compile.

./src/app/[countryCode]/(checkout)/checkout/page.tsx:23:44 Type error: Parameter 'cart' implicitly has an 'any' type.

21 | } 22 |

23 | const cart = await getCart(cartId).then((cart) => cart) | ^ 24 | 25 | if (cart?.items.length) { 26 | const enrichedItems = await enrichLineItems(cart?.items, cart?.region_id) error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

undercontr commented 5 months ago

@LXBUGR if you somehow accidentally removed the lock file, this is happens. i think this is mostly happens because of nexjs and typescript verison.

bruno-espino commented 2 months ago

Having, the same issue, with yarn 1.22:

yarn build yarn run v1.22.22 $ next build next.config.js {} ▲ Next.js 14.2.4

./src/modules/checkout/components/submit-button/index.tsx:26:7 Type error: Type '"primary" | "secondary" | "transparent" | "danger" | null' is not assignable to type '"primary" | "secondary" | "transparent" | "danger" | undefined'. Type 'null' is not assignable to type '"primary" | "secondary" | "transparent" | "danger" | undefined'.

24 | type="submit" 25 | isLoading={pending}

26 | variant={variant} | ^ 27 | data-testid={dataTestId} 28 | > 29 | {children} error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.`

grandpaSam commented 2 months ago

I am also having this same issue. A fresh download of this project will build correctly but later I will start getting these issues:

`

medusa-next@1.0.3 build next build

next.config.js {} ▲ Next.js 14.2.3

./src/modules/checkout/components/submit-button/index.tsx:26:7 Type error: Type '"primary" | "secondary" | "transparent" | "danger" | null' is not assignable to type '"primary" | "secondary" | "transparent" | "danger" | undefined'. Type 'null' is not assignable to type '"primary" | "secondary" | "transparent" | "danger" | undefined'.

24 | type="submit" 25 | isLoading={pending}

26 | variant={variant} | ^ 27 | data-testid={dataTestId} 28 | > 29 | {children}`

Gintasz commented 1 month ago

Same issue with pnpm run build... pnpm run dev appears to start the frontend server fine.

michsko544 commented 1 month ago

Same issue. Removing null from type helps