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

After Latest Build we are getting the following error

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.
1 Like

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

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

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.

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?

in our case, we are using monorepo.

1 Like

We are also using a monorepo

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

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

Please share your site @KrustyC.

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

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

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

Please share the site in question.

Site:
https://jss-nextjs-hosting.netlify.app/

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?

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?

@hrishikesh

Is there any chance to get:

  1. Next.js β€œpages based” site
  2. Next.js β€œAPI Routes” Routing: API Routes | Next.js

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)

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)

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

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

@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:

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