404 Error After Deploying Static Next.js 15 Project from Monorepo Using Netlify CLI

Hello,

I’m working on a project using Next.js v15.2.4 and React v18.3.1, and I’m trying to deploy it to Netlify as a statically prerendered site.

The project is structured as a monorepo, and the frontend app is located in the /apps/storefront subdirectory (where ‘apps‘ is a child of the root directory). For deployment, I’ve created a netlify.toml file inside /apps/storefront with the following configuration:

[build]
  publish = ".next"
  command = "npm run build"

[[plugins]]
  package = "@netlify/plugin-nextjs"

I’m using @netlify/plugin-nextjs version 5.13.1.

To deploy the site, I used the Netlify CLI:

  1. Logged in via netlify login

  2. Linked the /apps/storefront/ directory to my Netlify project using the appropriate projectId

  3. Ran netlify deploy --prod

Command output logs:

Netlify Build
────────────────────────────────────────────────────────────────

❯ Version
  @netlify/build 35.1.6

❯ Flags
  accountId: 6888df82601fb91956133181
  packagePath: apps\storefront

❯ Current directory
  C:\Users\a.cominelli\Desktop\Blue Reply\ecomm-playground\apps\storefront

❯ Config file
  C:\Users\a.cominelli\Desktop\Blue Reply\ecomm-playground\apps\storefront\netlify.toml

❯ Context
  production

❯ Using Next.js Runtime - v5.13.1

build.command from netlify.toml
────────────────────────────────────────────────────────────────

$ npm run build

> storefront@1.0.0 build
> next build

   ▲ Next.js 15.2.4
   - Environments: .env.production

   Creating an optimized production build ...
 ✓ Compiled successfully

./app/[locale]/(checkout)/cart/page.tsx
37:6  Warning: React Hook useEffect has a missing dependency: 'fetchCart'. Either include it or remove the dependency array.  react-hooks/exhaustive-deps

./app/[locale]/(checkout)/checkout/greetings/page.tsx
33:6  Warning: React Hook useEffect has missing dependencies: 'cartStore' and 'checkoutStore'. Either include them or remove the dependency array.  react-hooks/exhaustive-deps
43:6  Warning: React Hook useEffect has a missing dependency: 'getOrder'. Either include it or remove the dependency array.  react-hooks/exhaustive-deps

./app/[locale]/(checkout)/checkout/page.tsx
54:6  Warning: React Hook useEffect has a missing dependency: 'fetchCart'. Either include it or remove the dependency array.  react-hooks/exhaustive-deps
81:6  Warning: React Hook useEffect has a missing dependency: 'checkoutStore'. Either include it or remove the dependency array.  react-hooks/exhaustive-deps
85:6  Warning: React Hook useEffect has missing dependencies: 'cart' and 'navigateCheckoutSection'. Either include them or remove the dependency array.  react-hooks/exhaustive-deps

./app/[locale]/(rest)/my-account/AddressItem.tsx
26:16  Warning: Function 'AddressItem' has a complexity of 20. Maximum allowed is 8.  complexity

./app/[locale]/(rest)/my-account/page.tsx
35:16  Warning: Function 'MyAccountPage' has too many lines (414). Maximum allowed is 150.  max-lines-per-function
88:6  Warning: React Hook useEffect has a missing dependency: 'getOrders'. Either include it or remove the dependency array.  react-hooks/exhaustive-deps
111:6  Warning: React Hook useEffect has a missing dependency: 'setNotification'. Either include it or remove the dependency array.  react-hooks/exhaustive-deps
160:28  Warning: Arrow function has too many lines (223). Maximum allowed is 150.  max-lines-per-function
255:14  Warning: Do not nest ternary expressions.  no-nested-ternary
341:59  Warning: Forbidden non-null assertion.  @typescript-eslint/no-non-null-assertion
355:59  Warning: Forbidden non-null assertion.  @typescript-eslint/no-non-null-assertion
368:59  Warning: Forbidden non-null assertion.  @typescript-eslint/no-non-null-assertion

./app/[locale]/(rest)/my-account/ShippingInfoTab.tsx
45:27  Warning: Assignments to the 'initialLoadingState' variable from inside React Hook useEffect will be lost after each render. To preserve the value over time, store it in a useRef Hook and keep the mutable value in the '.current' property. Otherwise, you can move this variable directly inside useEffect.  react-hooks/exhaustive-deps
118:26  Warning: Unexpected any. Specify a different type.  @typescript-eslint/no-explicit-any
154:20  Warning: Forbidden non-null assertion.  @typescript-eslint/no-non-null-assertion

./app/[locale]/providers.tsx
8:14  Warning: Unexpected any. Specify a different type.  @typescript-eslint/no-explicit-any

./components/cms/CmsBodyRenderer/CmsBodyRenderer.tsx
15:12  Warning: Unexpected any. Specify a different type.  @typescript-eslint/no-explicit-any
17:20  Warning: Unexpected any. Specify a different type.  @typescript-eslint/no-explicit-any
22:27  Warning: Unexpected any. Specify a different type.  @typescript-eslint/no-explicit-any

./components/cms/LivePreview/PagePreviewRenderer.tsx
15:19  Warning: Unexpected any. Specify a different type.  @typescript-eslint/no-explicit-any
19:27  Warning: Unexpected any. Specify a different type.  @typescript-eslint/no-explicit-any
36:70  Warning: Unexpected any. Specify a different type.  @typescript-eslint/no-explicit-any
49:6  Warning: React Hook useCallback has a missing dependency: 'query'. Either include it or remove the dependency array.  react-hooks/exhaustive-deps
82:40  Warning: Identifier 'content_type_id' is not in camel case.  camelcase
86:30  Warning: Identifier 'content_type_id' is not in camel case.  camelcase

./components/cms/LivePreview/PreviewLayerComponent.tsx
11:12  Warning: Unexpected any. Specify a different type.  @typescript-eslint/no-explicit-any
20:17  Warning: Unexpected any. Specify a different type.  @typescript-eslint/no-explicit-any
37:42  Warning: Unexpected any. Specify a different type.  @typescript-eslint/no-explicit-any
38:48  Warning: Unexpected any. Specify a different type.  @typescript-eslint/no-explicit-any
49:25  Warning: Unexpected any. Specify a different type.  @typescript-eslint/no-explicit-any

./components/cms/NotFound/NotFound.tsx
50:6  Warning: React Hook useEffect has a missing dependency: 'fetchHeaderContent'. Either include it or remove the dependency array.  react-hooks/exhaustive-deps

./components/cms/Placeholders/PlpPlaceholder.tsx
6:16  Warning: Unexpected any. Specify a different type.  @typescript-eslint/no-explicit-any

./components/cms/ProductCarousel/mock.ts
1:27  Warning: Unexpected any. Specify a different type.  @typescript-eslint/no-explicit-any

./components/cms/PromoTopBar/PromoBar.tsx
43:6  Warning: React Hook useCallback has missing dependencies: 'locale' and 'variantParam'. Either include them or remove the dependency array.  react-hooks/exhaustive-deps
59:6  Warning: React Hook useEffect has a missing dependency: 'fetchFreshContent'. Either include it or remove the dependency array.  react-hooks/exhaustive-deps

./components/cms/RenderComponent.tsx
41:21  Warning: Unexpected any. Specify a different type.  @typescript-eslint/no-explicit-any
56:26  Warning: Unexpected any. Specify a different type.  @typescript-eslint/no-explicit-any

./components/external/Analytics.tsx
9:31  Warning: Unexpected any. Specify a different type.  @typescript-eslint/no-explicit-any

./components/layout/NavBarTop/NavBarTop.tsx
27:3  Warning: Arrow function has a complexity of 11. Maximum allowed is 8.  complexity

./components/layout/NavBarTop/SearchBar.tsx
37:45  Warning: Arrow function has too many lines (199). Maximum allowed is 150.  max-lines-per-function
37:45  Warning: Arrow function has a complexity of 16. Maximum allowed is 8.  complexity
136:6  Warning: React Hook useEffect has missing dependencies: 'fetchSearchSuggestion' and 'timeoutSearch'. Either include them or remove the dependency array.  react-hooks/exhaustive-deps

./components/layout/NavBarTop/SubMenuDesktop.tsx
29:6  Warning: React Hook useEffect has a missing dependency: 'cleanSubLabels'. Either include it or remove the dependency array. If 'cleanSubLabels' changes too often, find the parent component that defines it and wrap that definition in useCallback.  react-hooks/exhaustive-deps
88:32  Warning: Forbidden non-null assertion.  @typescript-eslint/no-non-null-assertion
89:33  Warning: Forbidden non-null assertion.  @typescript-eslint/no-non-null-assertion

./components/layout/NavBarTop/SubMenuMobile.tsx
12:57  Warning: Arrow function has a complexity of 11. Maximum allowed is 8.  complexity

./components/layout/types.ts
34:18  Warning: Unexpected any. Specify a different type.  @typescript-eslint/no-explicit-any

./components/pages/Content/ContentPage.tsx
85:18  Warning: Unexpected any. Specify a different type.  @typescript-eslint/no-explicit-any

./components/ui/Atoms/Button/DSButton.tsx
21:18  Warning: Arrow function has a complexity of 14. Maximum allowed is 8.  complexity

./components/ui/Atoms/Container/DSContainer.tsx
21:36  Warning: Unexpected any. Specify a different type.  @typescript-eslint/no-explicit-any

./components/ui/Atoms/Divider/DSDivider.tsx
22:9  Warning: Do not nest ternary expressions.  no-nested-ternary

./components/ui/Atoms/Form/DSForm.tsx
8:26  Warning: Unexpected any. Specify a different type.  @typescript-eslint/no-explicit-any
9:20  Warning: Unexpected any. Specify a different type.  @typescript-eslint/no-explicit-any
9:29  Warning: Unexpected any. Specify a different type.  @typescript-eslint/no-explicit-any

./components/ui/Atoms/Icons/CountryIcon.tsx
1:20  Warning: Arrow function has too many lines (204). Maximum allowed is 150.  max-lines-per-function

./components/ui/Atoms/Image/DSImage.tsx
20:7  Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element  @next/next/no-img-element

./components/ui/Atoms/Input/DSInput.tsx
34:17  Warning: Arrow function has a complexity of 14. Maximum allowed is 8.  complexity

./components/ui/Atoms/Loader/DsLoader.tsx
131:13  Warning: Do not nest ternary expressions.  no-nested-ternary

./components/ui/Atoms/Select/DsSelect.tsx
33:18  Warning: Arrow function has a complexity of 10. Maximum allowed is 8.  complexity

./components/ui/Atoms/Table/DSTable.tsx
38:61  Warning: Unexpected any. Specify a different type.  @typescript-eslint/no-explicit-any

./components/ui/Atoms/Toggle/DsToggle.tsx
65:18  Warning: Arrow function has a complexity of 13. Maximum allowed is 8.  complexity
103:5  Warning: Do not nest ternary expressions.  no-nested-ternary

./components/ui/Gallery/PreviewColumn.tsx
30:13  Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element  @next/next/no-img-element

./components/ui/Molecules/Cart/Cart.tsx
34:6  Warning: React Hook useEffect has a missing dependency: 'fetchCart'. Either include it or remove the dependency array.  react-hooks/exhaustive-deps

./components/ui/Molecules/Checkout/Delivery/DeliverySection.tsx
16:16  Warning: Function 'DeliverySection' has a complexity of 11. Maximum allowed is 8.  complexity
82:6  Warning: React Hook useEffect has a missing dependency: 'getShippingMethods'. Either include it or remove the dependency array.  react-hooks/exhaustive-deps
89:8  Warning: Do not nest ternary expressions.  no-nested-ternary

./components/ui/Molecules/Checkout/Delivery/PickUpSlot.tsx
13:11  Warning: Identifier 'PickUpPoint_Info' is not in camel case.  camelcase
19:12  Warning: Identifier 'PickUpPoint_Info' is not in camel case.  camelcase
20:19  Warning: Identifier 'PickUpPoint_Info' is not in camel case.  camelcase
25:12  Warning: Identifier 'PickUpPoint_Info' is not in camel case.  camelcase
28:12  Warning: Identifier 'PickUpPoint_Info' is not in camel case.  camelcase
28:43  Warning: Identifier 'PickUpPoint_Info' is not in camel case.  camelcase
31:12  Warning: Identifier 'PickUpPoint_Info' is not in camel case.  camelcase
31:43  Warning: Identifier 'PickUpPoint_Info' is not in camel case.  camelcase
31:68  Warning: Identifier 'PickUpPoint_Info' is not in camel case.  camelcase

./components/ui/Molecules/Checkout/Payment/PaymentSection.tsx
66:6  Warning: React Hook useEffect has a missing dependency: 'getPaymentMethods'. Either include it or remove the dependency array.  react-hooks/exhaustive-deps

./components/ui/Molecules/Checkout/Shipping/ShippingSection.tsx
54:6  Warning: React Hook useEffect has a missing dependency: 'getShippingMethods'. Either include it or remove the dependency array.  react-hooks/exhaustive-deps

./components/ui/Molecules/Scrollable/helper.ts
229:37  Warning: Unexpected any. Specify a different type.  @typescript-eslint/no-explicit-any

./components/ui/Molecules/Scrollable/Scrollable.tsx
18:37  Warning: Unexpected any. Specify a different type.  @typescript-eslint/no-explicit-any
83:55  Warning: Unexpected any. Specify a different type.  @typescript-eslint/no-explicit-any
84:26  Warning: Unexpected any. Specify a different type.  @typescript-eslint/no-explicit-any

./components/ui/Notification/utils.ts
26:12  Warning: Forbidden non-null assertion.  @typescript-eslint/no-non-null-assertion

./components/ui/OrderCard/OrderCard.tsx
33:15  Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element  @next/next/no-img-element

./components/ui/Plp/pageManager.ts
20:33  Warning: Unexpected any. Specify a different type.  @typescript-eslint/no-explicit-any
40:21  Warning: Arrow function has a complexity of 10. Maximum allowed is 8.  complexity
95:37  Warning: Unexpected any. Specify a different type.  @typescript-eslint/no-explicit-any
101:21  Warning: Unexpected any. Specify a different type.  @typescript-eslint/no-explicit-any

./components/ui/Plp/utils.ts
119:9  Warning: Unexpected any. Specify a different type.  @typescript-eslint/no-explicit-any
132:9  Warning: Unexpected any. Specify a different type.  @typescript-eslint/no-explicit-any

./components/ui/Registration/OTPSection.tsx
13:26  Warning: Unexpected any. Specify a different type.  @typescript-eslint/no-explicit-any

./components/ui/Registration/PasswordSection.tsx
17:26  Warning: Unexpected any. Specify a different type.  @typescript-eslint/no-explicit-any

./components/utils.ts
74:59  Warning: Unexpected any. Specify a different type.  @typescript-eslint/no-explicit-any

info  - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/app/api-reference/config/eslint#disabling-rules
 ✓ Linting and checking validity of types 
 ✓ Collecting page data    
 ✓ Generating static pages (42/42)
 ✓ Collecting build traces
 ✓ Finalizing page optimization 

Route (app)                                     Size  First Load JS  Revalidate  Expire
┌ ○ /_not-found                                982 B         102 kB
├ ● /[locale]                                  302 B         454 kB
├   ├ /en-us
├   └ /it-it
├ ● /[locale]/[slug]/[[...params]]             308 B         454 kB
├   ├ /it-it/test-landing-clothing
├   └ /en-us/test-landing-clothing
├ ● /[locale]/cart                           6.28 kB         150 kB
├   ├ /en-us/cart
├   └ /it-it/cart
├ ● /[locale]/category/[[...params]]           308 B         454 kB
├   ├ /en-us/category
├   ├ /en-us/category/test-landing-clothing
├   ├ /en-us/category/support
├   └ [+9 more paths]
├ ● /[locale]/checkout                       14.1 kB         171 kB
├   ├ /en-us/checkout
├   └ /it-it/checkout
├ ● /[locale]/checkout/greetings             3.33 kB         137 kB
├   ├ /en-us/checkout/greetings
├   └ /it-it/checkout/greetings
├ ● /[locale]/compare                          150 B         102 kB
├   ├ /en-us/compare
├   └ /it-it/compare
├ ● /[locale]/error                            150 B         102 kB
├   ├ /en-us/error
├   └ /it-it/error
├ ● /[locale]/favourites                     8.03 kB         146 kB
├   ├ /en-us/favourites
├   └ /it-it/favourites
├ ● /[locale]/login                          8.95 kB         148 kB
├   ├ /en-us/login
├   └ /it-it/login
├ ● /[locale]/maintenance                      278 B         102 kB
├   ├ /en-us/maintenance
├   └ /it-it/maintenance
├ ● /[locale]/my-account                     11.6 kB         221 kB
├   ├ /en-us/my-account
├   └ /it-it/my-account
├ ● /[locale]/not-found                      1.75 kB         455 kB
├   ├ /en-us/not-found
├   └ /it-it/not-found
├ ƒ /[locale]/product/[slug]/[[...params]]     302 B         454 kB
├ ƒ /[locale]/search/[[...params]]           1.31 kB         232 kB
├ ○ /robots.txt                                  0 B            0 B
└ ○ /sitemap.xml                               150 B         102 kB          1h      1y
+ First Load JS shared by all                 101 kB
  ├ chunks/8315-48676a6a61c28026.js            46 kB
  ├ chunks/87c73c54-ab30adfb0582e2c2.js      53.3 kB
  └ other shared chunks (total)              2.17 kB


ƒ Middleware                                 74.4 kB

○  (Static)   prerendered as static content
●  (SSG)      prerendered as static HTML (uses generateStaticParams)
ƒ  (Dynamic)  server-rendered on demand


(build.command completed in 2m 25s)

Functions bundling
────────────────────────────────────────────────────────────────

Packaging Functions from apps\storefront\.netlify\functions-internal directory:
 - ___netlify-server-handler\___netlify-server-handler.mjs


(Functions bundling completed in 19.3s)

Edge Functions bundling
────────────────────────────────────────────────────────────────

Packaging Edge Functions from apps\storefront\.netlify\edge-functions directory:
 - ___netlify-edge-handler-middleware

(Edge Functions bundling completed in 7.4s)

Deploying to Netlify
────────────────────────────────────────────────────────────────

Deploy path:        C:\Users\a.cominelli\Desktop\Blue Reply\ecomm-playground\apps\storefront\.next
Configuration path: C:\Users\a.cominelli\Desktop\Blue Reply\ecomm-playground\apps\storefront\netlify.toml

✔ Finished uploading blobs to deploy store
✔ No cached functions were found
✔ Finished hashing
✔ CDN requesting 6 files
✔ Finished uploading 9 assets
✔ Deploy is live!

Netlify Build Complete                                        
────────────────────────────────────────────────────────────────

(Netlify Build completed in 4m 22.1s)

🚀 Deploy complete
────────────────────────────────────────────────────────────────

   ╭─────────────────────────────── ⬥  Production deploy is live ⬥  ────────────────────────────────╮
   │                                                                                                │
   │             Deployed to production URL: https://ecommerce-accelerator.netlify.app              │
   │                                                                                                │
   │       Unique deploy URL: https://68c17e4535445f4cef16fbbd--ecommerce-accelerator.netlify.app   │
   │                                                                                                │
   ╰────────────────────────────────────────────────────────────────────────────────────────────────╯

Build logs:         https://app.netlify.com/projects/ecommerce-accelerator/deploys/68c17e4535445f4cef16fbbd
Function logs:      https://app.netlify.com/projects/ecommerce-accelerator/logs/functions
Edge function Logs: https://app.netlify.com/projects/ecommerce-accelerator/logs/edge-functions

The deployment completed successfully, and the site was made available at:

https://68c17e4535445f4cef16fbbd--ecommerce-accelerator.netlify.app

However, visiting this URL results in a 404 error.

Here are a few more technical details:

  • My next.config.js includes the following:
module.exports = {
  reactStrictMode: true,
  output: "standalone",
  //... other configuration
}

  • I cannot change the output setting from "standalone" to "export".

  • I cannot change the app routing or architectural specification.

  • I’m also unable to share the source code publicly.

Could someone help me understand why I’m encountering this 404 issue despite a successful deployment? Are there additional configurations required for standalone output in a monorepo context when using Netlify?

Any guidance would be greatly appreciated.

Thank you in advance.

If you’re using a monorepo, you should have the following netlify.toml in the apps/storefront directory:

[build]
  publish = "apps/storefront/.next"
  command = "npm run build"

[[plugins]]
  package = "@netlify/plugin-nextjs"

Then you should be running the following command from the root of your repo:

netlify deploy --filter=apps/storefront --prod

Hi, thank you for the quick response!

Now I noticed that my requests are correctly forwarded. Since I did not specify a different base directory neither a package directory, the publish directory pointed to a non existing output folder, am I right? From the documentation, I read

All paths configured in the netlify.toml should be absolute paths relative to the base directory, which is the root by default (/).

Unfortunately, once I hit the https://68c17e4535445f4cef16fbbd--ecommerce-accelerator.netlify.app link, I got this error:

This is the full function logs once I hit my site:

Sep 12, 06:08:22 PM: ERROR  Uncaught Exception 	{"errorType":"Error","errorMessage":"Cannot find package '\u000bar\taskappsstorefront' imported from /var/task/___netlify-server-handler.mjs","code":"ERR_MODULE_NOT_FOUND","stack":["Error [ERR_MODULE_NOT_FOUND]: Cannot find package '\u000bar\taskappsstorefront' imported from /var/task/___netlify-server-handler.mjs","    at Object.getPackageJSONURL (node:internal/modules/package_json_reader:268:9)","    at packageResolve (node:internal/modules/esm/resolve:774:81)","    at moduleResolve (node:internal/modules/esm/resolve:860:18)","    at moduleResolveWithNodePath (node:internal/modules/esm/resolve:990:14)","    at defaultResolve (node:internal/modules/esm/resolve:1033:79)","    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:780:12)","    at #cachedDefaultResolve (node:internal/modules/esm/loader:704:25)","    at ModuleLoader.resolve (node:internal/modules/esm/loader:687:38)","    at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:305:38)","    at ModuleJob._link (node:internal/modules/esm/module_job:137:49)"]}
Sep 12, 06:08:22 PM: INIT_REPORT Init Duration: 346.22 ms	Phase: init	Status: error	Error Type: Runtime.Unknown
Sep 12, 06:08:22 PM: ERROR  Uncaught Exception 	{"errorType":"Error","errorMessage":"Cannot find package '\u000bar\taskappsstorefront' imported from /var/task/___netlify-server-handler.mjs","code":"ERR_MODULE_NOT_FOUND","stack":["Error [ERR_MODULE_NOT_FOUND]: Cannot find package '\u000bar\taskappsstorefront' imported from /var/task/___netlify-server-handler.mjs","    at Object.getPackageJSONURL (node:internal/modules/package_json_reader:268:9)","    at packageResolve (node:internal/modules/esm/resolve:774:81)","    at moduleResolve (node:internal/modules/esm/resolve:860:18)","    at moduleResolveWithNodePath (node:internal/modules/esm/resolve:990:14)","    at defaultResolve (node:internal/modules/esm/resolve:1033:79)","    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:780:12)","    at #cachedDefaultResolve (node:internal/modules/esm/loader:704:25)","    at ModuleLoader.resolve (node:internal/modules/esm/loader:687:38)","    at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:305:38)","    at ModuleJob._link (node:internal/modules/esm/module_job:137:49)"]}
Sep 12, 06:08:23 PM: INIT_REPORT Init Duration: 250.53 ms	Phase: invoke	Status: error	Error Type: Runtime.Unknown
Sep 12, 06:08:23 PM: 86d68270 Duration: 337.46 ms	Memory Usage: 100 MB
Sep 12, 06:08:23 PM: ERROR  Uncaught Exception 	{"errorType":"Error","errorMessage":"Cannot find package '\u000bar\taskappsstorefront' imported from /var/task/___netlify-server-handler.mjs","code":"ERR_MODULE_NOT_FOUND","stack":["Error [ERR_MODULE_NOT_FOUND]: Cannot find package '\u000bar\taskappsstorefront' imported from /var/task/___netlify-server-handler.mjs","    at Object.getPackageJSONURL (node:internal/modules/package_json_reader:268:9)","    at packageResolve (node:internal/modules/esm/resolve:774:81)","    at moduleResolve (node:internal/modules/esm/resolve:860:18)","    at moduleResolveWithNodePath (node:internal/modules/esm/resolve:990:14)","    at defaultResolve (node:internal/modules/esm/resolve:1033:79)","    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:780:12)","    at #cachedDefaultResolve (node:internal/modules/esm/loader:704:25)","    at ModuleLoader.resolve (node:internal/modules/esm/loader:687:38)","    at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:305:38)","    at ModuleJob._link (node:internal/modules/esm/module_job:137:49)"]}
Sep 12, 06:08:23 PM: INIT_REPORT Init Duration: 252.76 ms	Phase: invoke	Status: error	Error Type: Runtime.Unknown
Sep 12, 06:08:23 PM: c2911e71 Duration: 333.24 ms	Memory Usage: 104 MB

It is not clear to me what is going on. To which module Netlify is referring to? Is it something installed by Netlify during the deployment stage? Or when I linked my local project to my Netlify project?

Does this happen when deploying from Netlify UI < - > Git repo? You can try using similar settings in the UI:

  • base directory unset
  • package directory: apps/storefront
  • publish directory: apps/storefront/.next

Could you also share a reproduction repo so we can test it? I’ve not seen this error before.

Indeed, setting up the package directory solved the problem and the site is up and running. The strange thing is that it seems that I cannot set the package directory directly in my netlify.toml file: I did not find anything related to this in the file configuration documentation.

Can you explain me why it works like this? I don’t understand why I can configure this value only from the Netlify UI and only if I link my repository.

Anyway, thank you for your support!

Package directory cannot be set in the toml as that config explicitly tells us where to look for the toml in the first place: Monorepos | Netlify Docs