Skip to content
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

The store works in dev mode(yarn dev), but does not compile for production(yarn buld). #352

Closed
og-dev opened this issue Aug 3, 2024 · 6 comments

Comments

@og-dev
Copy link

og-dev commented Aug 3, 2024

OS: Ubuntu 20.04
Node: 18.18.0

Fail due Type error: Parameter 'c' implicitly has an 'any' type.

yarn run v1.22.22
$ next build
next.config.js {}
  ▲ Next.js 14.2.5
  - Environments: .env.local

   Creating an optimized production build ...
next.config.js {}
next.config.js {}
next.config.js {}
 ✓ Compiled successfully
   Linting and checking validity of types  ...Failed to compile.

./src/modules/checkout/components/shipping-address/index.tsx:37:39
Type error: Parameter 'c' implicitly has an 'any' type.

  35 |
  36 |   const countriesInRegion = useMemo(
> 37 |     () => cart?.region.countries.map((c) => c.iso_2),
     |                                       ^
  38 |     [cart?.region]
  39 |   )
  40 |
error Command failed with exit code 1.

if strict is disbled in tsconfig then: Linting and checking validity of types ..Failed to compile.

store-storefront# yarn build
yarn run v1.22.22
$ next build
next.config.js {}
  ▲ Next.js 14.2.5
  - Environments: .env.local

   Creating an optimized production build ...
next.config.js {}
next.config.js {}
next.config.js {}
 ✓ Compiled successfully
   Linting and checking validity of types  ..Failed to compile.

./src/app/[countryCode]/(main)/cart/page.tsx:37:3
Type error: Type '"" | "address" | "delivery" | "payment"' is not assignable to type '"address" | "payment" | "delivery"'.

  35 |   }
  36 |
> 37 |   cart.checkout_step = cart && getCheckoutStep(cart)
     |   ^
  38 |
  39 |   return cart
  40 | }
error Command failed with exit code 1.

Is there a way to fix those error?

I tried to fix the second error by changing @types/react, @types/react-dom but it did not work

@anzweidrej
Copy link

anzweidrej commented Aug 5, 2024

Hi @og-dev,

As you already guessed, this is due to the "strict" mode enabled in tsconfig, to solve the error without having to disable the option, you can try the following solutions:

Option 1:

const countriesInRegion = useMemo(
    () => cart?.region.countries.map((c: { iso_2: string }) => c.iso_2),
    [cart?.region]
  )

Option 2:

type CountryProps = {
  iso_2: string;
};

const countriesInRegion = useMemo(
  () => cart?.region.countries.map((c: CountryProps) => c.iso_2),
  [cart?.region]
);

@adambarath
Copy link

I had the same issue. See my comment at: #279 (comment)

@VariableVic
Copy link
Collaborator

Should be fixed with the Next.js 15 update. Closing this for now.

@dapinitial
Copy link

dapinitial commented Jan 15, 2025

Running Node v23 and NPM v10.9.1

Maybe related to this post...

I am trying to deploy the frontend to Azure Container using Docker. Backend builds and deploys no issues, and running the application locally is smooth and no issues... However, when building the storefront during deployment I am getting the following issue:

▲ Next.js 15.0.3

  • Environments: .env.local

Creating an optimized production build ...
[webpack.cache.PackFileCacheStrategy] Caching failed for pack: Error: Unable to snapshot resolve dependencies
[webpack.cache.PackFileCacheStrategy] Caching failed for pack: Error: Unable to snapshot resolve dependencies
[webpack.cache.PackFileCacheStrategy] Caching failed for pack: Error: Unable to snapshot resolve dependencies
✓ Compiled successfully
Skipping validation of types
Skipping linting
✓ Collecting page data
Failed to build /[countryCode]/(main)/categories/[...category]/page: /es/categories/sweatshirts (attempt 1 of 3) because it took more than 300 seconds. Retrying again shortly.
Failed to build /[countryCode]/(main)/categories/[...category]/page: /es/categories/pants (attempt 1 of 3) because it took more than 300 seconds. Retrying again shortly.
Failed to build /[countryCode]/(main)/categories/[...category]/page: /es/categories/merch (attempt 1 of 3) because it took more than 300 seconds. Retrying again shortly.
Failed to build /[countryCode]/(main)/categories/[...category]/page: /fr/categories/sweatshirts (attempt 1 of 3) because it took more than 300 seconds. Retrying again shortly.
Failed to build /[countryCode]/(main)/categories/[...category]/page: /fr/categories/pants (attempt 1 of 3) because it took more than 300 seconds. Retrying again shortly.
Failed to build /[countryCode]/(main)/categories/[...category]/page: /fr/categories/merch (attempt 1 of 3) because it took more than 300 seconds. Retrying again shortly.
Failed to build /[countryCode]/(main)/categories/[...category]/page: /de/categories/sweatshirts (attempt 1 of 3) because it took more than 300 seconds. Retrying again shortly.
Failed to build /[countryCode]/(main)/categories/[...category]/page: /de/categories/pants (attempt 1 of 3) because it took more than 300 seconds. Retrying again shortly.

@JulianBerger
Copy link

@dapinitial I'm getting the same error.

@ozbrandcc
Copy link

ozbrandcc commented Jan 29, 2025

Im getting the same error, any news?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants