medusajs / medusa

Building blocks for digital commerce
https://medusajs.com
MIT License
23.95k stars 2.32k forks source link

Unable to run storefront in production because of build errors #7571

Open AwaaX opened 1 month ago

AwaaX commented 1 month ago

Preliminary Checks

Issue Summary

I get type error "Type error: Unused '@ts-expect-error' directive." when trying to run build so i can't use storefront in production mode

How can this issue be resolved?

No idea

Are you interested in working on this issue? Sorry I'm not a developer I am a e-commerce company holder testing medusa

sradevski commented 1 month ago

@AwaaX I can build the project without issues. Can you please provide more information to reproduce the issue from a clean clone? What command did you run? Are you running main? What is your node/yarn version?

What are you trying to run, the starter project?

matmar10 commented 1 month ago

@sradevski I am also facing this issue with a completely clean (out of the box) install.

I have created a clean install that replicates the issue here: matmar10/medusa-storefront

Steps to reproduce:

This is using Node v20.12.2

  1. npx create-next-app -e https://github.com/medusajs/nextjs-starter-medusa my-medusa-storefront
  2. cd my-medusa-storefront
  3. npm run build

Expected behavior:

  1. Project builds okay out of the box -or-
  2. Removing the @ts-expect-error allows to build

Actual behavior

./src/modules/products/components/product-tabs/accordion.tsx:57:8
Type error: Unused '@ts-expect-error' directive.

  55 |       )}
  56 |     >
> 57 |       {/* @ts-expect-error */}
     |        ^
  58 |       <AccordionPrimitive.Header className="px-1">
  59 |         <div className="flex flex-col">
  60 |           <div className="flex w-full items-center justify-between">

Screenshot 2024-06-12 at 2 53 11 PM

Work-Around / Fix

You can resolve the issue by leaving the first @ts-expect-error and removing the remaining ones:

diff --git a/src/modules/products/components/product-tabs/accordion.tsx b/src/modules/products/components/product-tabs/accordion.tsx
index db8855a..03d837a 100644
--- a/src/modules/products/components/product-tabs/accordion.tsx
+++ b/src/modules/products/components/product-tabs/accordion.tsx
@@ -54,14 +54,12 @@ const Item: React.FC<AccordionItemProps> = ({
         className
       )}
     >
-      {/* @ts-expect-error */}
       <AccordionPrimitive.Header className="px-1">
         <div className="flex flex-col">
           <div className="flex w-full items-center justify-between">
             <div className="flex items-center gap-4">
               <Text className="text-ui-fg-subtle text-sm">{title}</Text>
             </div>
-            {/* @ts-expect-error */}
             <AccordionPrimitive.Trigger>
               {customTrigger || <MorphingTrigger />}
             </AccordionPrimitive.Trigger>
@@ -73,7 +71,6 @@ const Item: React.FC<AccordionItemProps> = ({
           )}
         </div>
       </AccordionPrimitive.Header>
-      {/* @ts-expect-error */}
       <AccordionPrimitive.Content
         forceMount={forceMountContent}
         className={clx(
andresrivero commented 1 week ago

I had this error as well with npm, I tried the fix above but got a different error - tried adding @medusajs/types but no luck.

I deleted my .node-modules and then used yarn, yarn dev, and yarn build - it ran successfully and built the next app

santiblanko commented 1 week ago

same here with node 20