# Runtime.ImportModuleError - Error: Cannot find module '../../../.next/required-server-files.json

**URL:** <https://answers.netlify.com/t/runtime-importmoduleerror-error-cannot-find-module-next-required-server-files-json/77654>\
**Category:** Support\
**Tags:** lambda-functions, netlify-api, nextjs\
**Created:** [October 19, 2022, 9:34am UTC](https://answers.netlify.com/t/runtime-importmoduleerror-error-cannot-find-module-next-required-server-files-json/77654 "2022-10-19T09:34:20Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![pranshushah](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/pranshushah/32/42231_2.png) [@pranshushah](https://answers.netlify.com/u/pranshushah)\
**Post date:** [October 19, 2022, 9:34am UTC](https://answers.netlify.com/t/runtime-importmoduleerror-error-cannot-find-module-next-required-server-files-json/77654/1 "2022-10-19T09:34:20Z")

</div>

After Latest Build we are getting the following error

```auto
Runtime.ImportModuleError: Error: Cannot find module '../../../.next/required-server-files.json'
Require stack:
- /var/task/.netlify/functions-internal/_api_auth_auth0-SPLAT-handler/_api_auth_auth0-SPLAT-handler.js
- /var/task/_api_auth_auth0-SPLAT-handler.js
- /var/runtime/index.mjs
    at _loadUserApp (file:///var/runtime/index.mjs:951:17)
    at async Object.UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:976:21)
    at async start (file:///var/runtime/index.mjs:1137:23)
    at async file:///var/runtime/index.mjs:1143:1

```

- we have not changed the given function for a long time and the version of next.js and auth0-next.js also hasn’t changed for a lone time.

---

<div class="post-metadata">

**Author:** ![pranshushah](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/pranshushah/32/42231_2.png) [@pranshushah](https://answers.netlify.com/u/pranshushah)\
**Post date:** [October 19, 2022, 9:38am UTC](https://answers.netlify.com/t/runtime-importmoduleerror-error-cannot-find-module-next-required-server-files-json/77654/2 "2022-10-19T09:38:56Z")

</div>

name of website `https://dev.app.invact.com/` .

---

<div class="post-metadata">

**Author:** ![0xbobsky](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/0xbobsky/32/42272_2.png) [@0xbobsky](https://answers.netlify.com/u/0xbobsky)\
**Post date:** [October 19, 2022, 10:23am UTC](https://answers.netlify.com/t/runtime-importmoduleerror-error-cannot-find-module-next-required-server-files-json/77654/3 "2022-10-19T10:23:06Z")

</div>

We are also seeing this error - looks like yesterday’s release of @netlify/plugin-nextjs broke it.

---

<div class="post-metadata">

**Author:** ![0xbobsky](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/0xbobsky/32/42272_2.png) [@0xbobsky](https://answers.netlify.com/u/0xbobsky)\
**Post date:** [October 19, 2022, 10:42am UTC](https://answers.netlify.com/t/runtime-importmoduleerror-error-cannot-find-module-next-required-server-files-json/77654/5 "2022-10-19T10:42:52Z")

</div>

We’ve mitigated this issue by locking the build plugin to an earlier version (4.26) - you can do that by adding `@netlify/plugin-nextjs@4.26` as a dev dependency.

Make sure you don’t delete the versionless plugin from `netlify.toml` or it won’t build.

---

<div class="post-metadata">

**Author:** ![ascorbic](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/ascorbic/32/25858_2.png) [@ascorbic](https://answers.netlify.com/u/ascorbic)\
**Post date:** [October 19, 2022, 10:53am UTC](https://answers.netlify.com/t/runtime-importmoduleerror-error-cannot-find-module-next-required-server-files-json/77654/7 "2022-10-19T10:53:13Z")

</div>

Thanks for the report. I’m rolling back the auto-installed version to 4.26.0 while we investigate. Could anyone experiencing this let me know if they’re using a monorepo, or if there’s anything unusual about their setup?

---

<div class="post-metadata">

**Author:** ![pranshushah](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/pranshushah/32/42231_2.png) [@pranshushah](https://answers.netlify.com/u/pranshushah)\
**Post date:** [October 19, 2022, 10:53am UTC](https://answers.netlify.com/t/runtime-importmoduleerror-error-cannot-find-module-next-required-server-files-json/77654/8 "2022-10-19T10:53:52Z")

</div>

in our case, we are using monorepo.

---

<div class="post-metadata">

**Author:** ![0xbobsky](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/0xbobsky/32/42272_2.png) [@0xbobsky](https://answers.netlify.com/u/0xbobsky)\
**Post date:** [October 19, 2022, 11:28am UTC](https://answers.netlify.com/t/runtime-importmoduleerror-error-cannot-find-module-next-required-server-files-json/77654/9 "2022-10-19T11:28:55Z")

</div>

We are also using a monorepo

---

<div class="post-metadata">

**Author:** ![ascorbic](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/ascorbic/32/25858_2.png) [@ascorbic](https://answers.netlify.com/u/ascorbic)\
**Post date:** [October 19, 2022, 11:30am UTC](https://answers.netlify.com/t/runtime-importmoduleerror-error-cannot-find-module-next-required-server-files-json/77654/10 "2022-10-19T11:30:38Z")

</div>

I’ve isolated the problem and will have a fix out shortly. Thanks everyone for your information.

---

<div class="post-metadata">

**Author:** ![KrustyC](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/krustyc/32/50032_2.png) [@KrustyC](https://answers.netlify.com/u/KrustyC)\
**Post date:** [May 12, 2023, 4:53am UTC](https://answers.netlify.com/t/runtime-importmoduleerror-error-cannot-find-module-next-required-server-files-json/77654/11 "2023-05-12T04:53:01Z")

</div>

Has a solution for this been release already? I am on @netlify/plugin-nextjs 4.36.0 and I still see this issue

---

<div class="post-metadata">

**Author:** ![hrishikesh](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hrishikesh/32/74607_2.png) [@hrishikesh](https://answers.netlify.com/u/hrishikesh)\
**Post date:** [May 13, 2023, 6:44pm UTC](https://answers.netlify.com/t/runtime-importmoduleerror-error-cannot-find-module-next-required-server-files-json/77654/12 "2023-05-13T18:44:51Z")

</div>

Please share your site @KrustyC.

---

<div class="post-metadata">

**Author:** ![jeromel1978](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/jeromel1978/32/55550_2.png) [@jeromel1978](https://answers.netlify.com/u/jeromel1978)\
**Post date:** [November 29, 2023, 4:36pm UTC](https://answers.netlify.com/t/runtime-importmoduleerror-error-cannot-find-module-next-required-server-files-json/77654/13 "2023-11-29T16:36:21Z")

</div>

I have been getting this issue now, too. My project is on v4.41.2

---

<div class="post-metadata">

**Author:** ![hrishikesh](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hrishikesh/32/74607_2.png) [@hrishikesh](https://answers.netlify.com/u/hrishikesh)\
**Post date:** [December 2, 2023, 3:35pm UTC](https://answers.netlify.com/t/runtime-importmoduleerror-error-cannot-find-module-next-required-server-files-json/77654/14 "2023-12-02T15:35:42Z")

</div>

We can’t do much without seeing the site in question.

---

<div class="post-metadata">

**Author:** ![Antonytm](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/antonytm/32/20612_2.png) [@Antonytm](https://answers.netlify.com/u/Antonytm)\
**Post date:** [February 19, 2024, 9:14pm UTC](https://answers.netlify.com/t/runtime-importmoduleerror-error-cannot-find-module-next-required-server-files-json/77654/15 "2024-02-19T21:14:54Z")

</div>

The same issue after update from  
“@netlify/plugin-nextjs”: “^4.39.4”  
to  
“@netlify/plugin-nextjs”: “^4.41.3”

And it happens only when I pass `--skip-functions-cache`

---

<div class="post-metadata">

**Author:** ![SamO](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/samo/32/41847_2.png) [@SamO](https://answers.netlify.com/u/SamO)\
**Post date:** [February 20, 2024, 4:12pm UTC](https://answers.netlify.com/t/runtime-importmoduleerror-error-cannot-find-module-next-required-server-files-json/77654/16 "2024-02-20T16:12:44Z")

</div>

Please share the site in question.

---

<div class="post-metadata">

**Author:** ![Antonytm](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/antonytm/32/20612_2.png) [@Antonytm](https://answers.netlify.com/u/Antonytm)\
**Post date:** [February 20, 2024, 11:32pm UTC](https://answers.netlify.com/t/runtime-importmoduleerror-error-cannot-find-module-next-required-server-files-json/77654/17 "2024-02-20T23:32:49Z")

</div>

Site:  
[https://jss-nextjs-hosting.netlify.app/](https://jss-nextjs-hosting.netlify.app/)

---

<div class="post-metadata">

**Author:** ![hrishikesh](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hrishikesh/32/74607_2.png) [@hrishikesh](https://answers.netlify.com/u/hrishikesh)\
**Post date:** [February 21, 2024, 2:55pm UTC](https://answers.netlify.com/t/runtime-importmoduleerror-error-cannot-find-module-next-required-server-files-json/77654/18 "2024-02-21T14:55:00Z")

</div>

This would be resolved in the upcoming Next.js Runtime v5.

However, could you confirm you’re not trying to use a monorepo and if you’re, you’ve gone thorugh: [Monorepos | Netlify Docs](https://docs.netlify.com/configure-builds/monorepos/)?

---

<div class="post-metadata">

**Author:** ![Antonytm](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/antonytm/32/20612_2.png) [@Antonytm](https://answers.netlify.com/u/Antonytm)\
**Post date:** [February 21, 2024, 6:23pm UTC](https://answers.netlify.com/t/runtime-importmoduleerror-error-cannot-find-module-next-required-server-files-json/77654/19 "2024-02-21T18:23:36Z")

</div>

No, I don’t use Monorepos.

Is there are solution for now?  
Because it blocks development. Netlify has either a broken version or an old one. Do you have any plugin version for Next that you can recommend?

---

<div class="post-metadata">

**Author:** ![Antonytm](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/antonytm/32/20612_2.png) [@Antonytm](https://answers.netlify.com/u/Antonytm)\
**Post date:** [February 22, 2024, 11:13am UTC](https://answers.netlify.com/t/runtime-importmoduleerror-error-cannot-find-module-next-required-server-files-json/77654/20 "2024-02-22T11:13:31Z")

</div>

@hrishikesh

Is there any chance to get:

1. Next.js “pages based” site
2. Next.js “API Routes” [Routing: API Routes | Next.js](https://nextjs.org/docs/pages/building-your-application/routing/api-routes)

deployment without the issues?

**If yes, then what versions of Next.js and @netlify/plugin-nextjs should I use?**  
Are there any other requirements?

Or is better not to use “Next.js API routes”? And replace them Netlify functions?  
([Netlify Functions](https://www.netlify.com/platform/core/functions/))

I understand, that something may not work. I want to get some recommendations in this area. Working scenario description or description of knowing limitations. Because the more I look into the more I have doubts that it is supposed to work at all…

I tried different versions of `@netlify/plugin-nextjs`, and different deployment methods(from the console, from the browser interface) with no luck. I either have build errors or runtime errors that say something wrong with bundling or weird cache issues, when I get old code for “API Routes” to be deployed.

About V5, that you suggested, it doesn’t work at all:  
(expected as it is in beta)

```auto
Plugin "@netlify/plugin-nextjs" failed
────────────────────────────────────────────────────────────────

  Error message
  Error: Failed publishing static content

  Plugin details
  Package: @netlify/plugin-nextjs
  Version: 5.0.0-beta.9
  Repository: git+https://github.com/netlify/next-runtime-minimal.git
  npm link: https://www.npmjs.com/package/@netlify/plugin-nextjs
  Report issues: https://github.com/netlify/next-runtime-minimal/issues

  Error location
  In "onPostBuild" event in "@netlify/plugin-nextjs" from netlify.toml and package.json

```

---

<div class="post-metadata">

**Author:** ![hrishikesh](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hrishikesh/32/74607_2.png) [@hrishikesh](https://answers.netlify.com/u/hrishikesh)\
**Post date:** [February 22, 2024, 2:43pm UTC](https://answers.netlify.com/t/runtime-importmoduleerror-error-cannot-find-module-next-required-server-files-json/77654/21 "2024-02-22T14:43:37Z")

</div>

> [@Antonytm](#):
>
> About V5, that you suggested, it doesn’t work at all:

This is a highly unactionable piece of error message that you’ve shared. Please share the full logs.

---

<div class="post-metadata">

**Author:** ![Antonytm](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/antonytm/32/20612_2.png) [@Antonytm](https://answers.netlify.com/u/Antonytm)\
**Post date:** [February 22, 2024, 5:24pm UTC](https://answers.netlify.com/t/runtime-importmoduleerror-error-cannot-find-module-next-required-server-files-json/77654/22 "2024-02-22T17:24:13Z")

</div>

@hrishikesh

There is no more useful information!  
`netlify` CLI and `@netlify/plugin-nextjs` provide this “highly unactionable piece of error message” as you wrote.

You need to fix it either on the CLI or on the plugin side to provide an “actionable” error message. And don’t blame users, if they send you a log that is “unactionable”.

The full log:

```auto
PS C:\source\next-js-netlify\nextjs> netlify deploy --prod --build --skip-functions-cache

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

❯ Version
  @netlify/build 29.35.1

❯ Flags
  {}

❯ Current directory
  C:\source\next-js-netlify\nextjs

❯ Config file
  C:\source\next-js-netlify\nextjs\netlify.toml

❯ Context
  dev

❯ Using Next.js Runtime - v5.0.0-beta.9

Cleaning up leftover files from previous builds
────────────────────────────────────────────────────────────────

(Pre cleanup completed in 4ms)

@netlify/plugin-nextjs (onPreBuild event)
────────────────────────────────────────────────────────────────

(@netlify/plugin-nextjs onPreBuild completed in 14ms)

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

$ npm run build

> nextjs@21.5.3 build
> npm-run-all --serial bootstrap next:build

> nextjs@21.5.3 bootstrap
> ts-node --project tsconfig.scripts.json scripts/bootstrap.ts && graphql-let

Registering config plugin computed
Registering config plugin disconnected
Registering config plugin fallback
Registering config plugin package-json
Registering config plugin scjssconfig
Writing config plugins to C:\source\next-js-netlify\nextjs\scripts\temp\config-plugins.ts
Registering sitemap-fetcher plugin disconnected-sitemap-service
Registering sitemap-fetcher plugin graphql-sitemap-service
Writing sitemap-fetcher plugins to C:\source\next-js-netlify\nextjs\src\temp\sitemap-fetcher-plugins.ts
Writing middleware plugins to C:\source\next-js-netlify\nextjs\src\temp\middleware-plugins.ts
Registering page-props-factory plugin component-props
Registering page-props-factory plugin normal-mode
Registering page-props-factory plugin preview-mode
Registering page-props-factory plugin site
Writing page-props-factory plugins to C:\source\next-js-netlify\nextjs\src\temp\page-props-factory-plugins.ts
Registering next-config plugin disconnected
Registering next-config plugin graphql
Registering next-config plugin styleguide
Writing next-config plugins to C:\source\next-js-netlify\nextjs\src\temp\next-config-plugins.js
Writing extract-path plugins to C:\source\next-js-netlify\nextjs\src\temp\extract-path-plugins.ts
Registering site-resolver plugin default
Writing site-resolver plugins to C:\source\next-js-netlify\nextjs\src\temp\site-resolver-plugins.ts
Registering JSS component ContentBlock
Registering JSS component FEaaSWrapper
Registering JSS component Styleguide-FieldUsage-Checkbox
Registering JSS component Styleguide-FieldUsage-ContentList
Registering JSS component Styleguide-FieldUsage-Custom
Registering JSS component Styleguide-FieldUsage-Date
Registering JSS component Styleguide-FieldUsage-File
Registering JSS component Styleguide-FieldUsage-Image
Registering JSS component Styleguide-FieldUsage-ItemLink
Registering JSS component Styleguide-FieldUsage-Link
Registering JSS component Styleguide-FieldUsage-Number
Registering JSS component Styleguide-FieldUsage-RichText
Registering JSS component Styleguide-FieldUsage-Text
Registering JSS component GraphQL-ConnectedDemo.dynamic
Registering JSS component GraphQL-IntegratedDemo
Registering JSS component GraphQL-Layout
Registering JSS component Styleguide-ComponentParams
Registering JSS component Styleguide-CustomRouteType
Registering JSS component Styleguide-EditFrame
Registering JSS component Styleguide-Layout-Reuse
Registering JSS component Styleguide-Layout-Tabs-Tab
Registering JSS component Styleguide-Layout-Tabs
Registering JSS component Styleguide-Layout
Registering JSS component Styleguide-Multilingual
Registering JSS component Styleguide-RouteFields
Registering JSS component Styleguide-Section
Registering JSS component Styleguide-SitecoreContext
Registering JSS component Styleguide-Specimen
Registering JSS component Styleguide-Tracking
Writing component factory to C:\source\next-js-netlify\nextjs\src\temp\componentFactory.ts
Writing runtime config to C:\source\next-js-netlify\nextjs\src\temp\config.js
[graphql-let] Nothing to do. Caches for 2 GraphQL documents are fresh.

> nextjs@21.5.3 next:build
> next build

- info Loaded env from C:\source\next-js-netlify\nextjs\.env
- info Linting and checking validity of types
- info Disabled SWC as replacement for Babel because of custom Babel configuration ".babelrc" https://nextjs.org/docs/messages/swc-disabled
- info Using external babel configuration from C:\source\next-js-netlify\nextjs\.babelrc
- warn It looks like there is a custom Babel configuration can be removed .
[graphql-let] Nothing to do. Cache was fresh.
Browserslist: caniuse-lite is outdated. Please run:
  npx browserslist@latest --update-db
[graphql-let] Nothing to do. Cache was fresh.
- warn Compiled with warnings

./src/lib/sitemap-fetcher/plugins/disconnected-sitemap-service.ts
Module not found: Can't resolve 'sitecore/manifest/sitecore-import.json' in 'C:\source\next-js-netlify\nextjs\src\lib\sitemap-fetcher\plugins'

Import trace for requested module:
./src/lib/sitemap-fetcher/plugins/disconnected-sitemap-service.ts
./src/temp/sitemap-fetcher-plugins.ts
./src/lib/sitemap-fetcher/index.ts
./src/pages/[[...path]].tsx

- info Collecting page data
- info Generating static pages (9/9)
- info Finalizing page optimization

- info Creating an optimized production build .Route (pages) Size First Load JS
┌ /_app 0 B 91.5 kB
├ ● /[[...path]] (16296 ms) 109 kB 201 kB
├ ├ /en/graphql (3062 ms)
├ ├ /en/styleguide (2674 ms)
├ ├ /en/graphql/sample-1 (2654 ms)
├ ├ /en/graphql/sample-2 (2653 ms)
├ ├ /en/styleguide/custom-route-type (2640 ms)
├ └ /en (2613 ms)
├ ○ /404 1.91 kB 93.4 kB
├ λ /api/editing/data/[key] 0 B 91.5 kB
├ λ /api/editing/render 0 B 91.5 kB
├ λ /api/env 0 B 91.5 kB
├ λ /api/healthz 0 B 91.5 kB
└ λ /api/test 0 B 91.5 kB
+ First Load JS shared by all 119 kB
  ├ chunks/framework-63157d71ad419e09.js 45.2 kB
  ├ chunks/main-e49d4f046eca46f6.js 41.4 kB
  ├ chunks/pages/_app-62a0abcc8bb1479e.js 3.07 kB
  ├ chunks/webpack-dcf2ae1fc51af409.js 1.87 kB
  └ css/ad2ef081ae3c7779.css 27.7 kB

ƒ Middleware 26.2 kB

λ (Server) server-side renders at runtime (uses getInitialProps or getServerSideProps)
○ (Static) automatically rendered as static HTML (uses no initial props)
● (SSG) automatically generated as static HTML + JSON (uses getStaticProps)

(build.command completed in 55.2s)

@netlify/plugin-nextjs (onBuild event)
────────────────────────────────────────────────────────────────

(@netlify/plugin-nextjs onBuild completed in 5s)

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

Packaging Functions from .netlify\functions-internal directory:
 - ___netlify-server-handler\___ netlify-server-handler.mjs
No Functions were found in netlify\functions directory

(Functions bundling completed in 14.4s)

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

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

(Edge Functions bundling completed in 4.1s)

@netlify/plugin-nextjs (onPostBuild event)                      
────────────────────────────────────────────────────────────────

@netlify/plugin-nextjs (onEnd event)                            
────────────────────────────────────────────────────────────────

(@netlify/plugin-nextjs onEnd completed in 12ms)

Save updated config                                             
────────────────────────────────────────────────────────────────

(options.onEnd completed in 3ms)

Plugin "@netlify/plugin-nextjs" failed
────────────────────────────────────────────────────────────────

  Error message
  Error: Failed publishing static content

  Plugin details
  Package: @netlify/plugin-nextjs
  Version: 5.0.0-beta.9
  Repository: git+https://github.com/netlify/next-runtime-minimal.git
  npm link: https://www.npmjs.com/package/@netlify/plugin-nextjs
  Report issues: https://github.com/netlify/next-runtime-minimal/issues

  Error location
  In "onPostBuild" event in "@netlify/plugin-nextjs" from netlify.toml and package.json

  Resolved config
  build:
    base: C:\source\next-js-netlify\nextjs
    command: npm run build
    commandOrigin: config
    publish: C:\source\next-js-netlify\nextjs\.next
    publishOrigin: config
  functionsDirectory: C:\source\next-js-netlify\nextjs\netlify\functions
  plugins:
    - inputs: {}
      origin: config
      package: '@netlify/plugin-nextjs'
  redirects:
    - from: /_next/image
      query:
        q: ':quality'
        url: ':url'
        w: ':width'
      status: 200
      to: /.netlify/images?url=:url&w=:width&q=:quality
  redirectsOrigin: inline

```

[Next page](https://answers.netlify.com/t/runtime-importmoduleerror-error-cannot-find-module-next-required-server-files-json/77654.md?page=2)
