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

I need to run with --debug flag to get something useful

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

Packaging Edge Functions from .netlify\edge-functions directory:
 - ___netlify-edge-handler-src-middleware
Local version of types is up-to-date: 65cdde7e22d9659a5097632a
getBinaryVersion failed Error: Command failed with exit code 1: deno --version
'deno' is not recognized as an internal or external command,
operable program or batch file.
    at makeError (file:///C:/Users/Anton/AppData/Roaming/nvm/v18.17.0/node_modules/netlify-cli/node_modules/@netlify/edge-bundler/node_modules/execa/lib/error.js:59:11)
    at handlePromise (file:///C:/Users/Anton/AppData/Roaming/nvm/v18.17.0/node_modules/netlify-cli/node_modules/@netlify/edge-bundler/node_modules/execa/index.js:119:26)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async DenoBridge.getBinaryVersion (file:///C:/Users/Anton/AppData/Roaming/nvm/v18.17.0/node_modules/netlify-cli/node_modules/@netlify/edge-bundler/dist/node/bridge.js:49:32)
    at async DenoBridge.getGlobalBinary (file:///C:/Users/Anton/AppData/Roaming/nvm/v18.17.0/node_modules/netlify-cli/node_modules/@netlify/edge-bundler/dist/node/bridge.js:83:31)
    at async DenoBridge.getBinaryPath (file:///C:/Users/Anton/AppData/Roaming/nvm/v18.17.0/node_modules/netlify-cli/node_modules/@netlify/edge-bundler/dist/node/bridge.js:122:28)
    at async DenoBridge.run (file:///C:/Users/Anton/AppData/Roaming/nvm/v18.17.0/node_modules/netlify-cli/node_modules/@netlify/edge-bundler/dist/node/bridge.js:147:38)
    at async bundleESZIP (file:///C:/Users/Anton/AppData/Roaming/nvm/v18.17.0/node_modules/netlify-cli/node_modules/@netlify/edge-bundler/dist/node/formats/eszip.js:33:9)
    at async bundle (file:///C:/Users/Anton/AppData/Roaming/nvm/v18.17.0/node_modules/netlify-cli/node_modules/@netlify/edge-bundler/dist/node/bundler.js:62:28)
    at async coreStep (file:///C:/Users/Anton/AppData/Roaming/nvm/v18.17.0/node_modules/netlify-cli/node_modules/@netlify/build/lib/plugins_core/edge_functions/index.js:44:30) {
  shortMessage: 'Command failed with exit code 1: deno --version',
  command: 'deno --version',
  escapedCommand: 'deno --version',
  exitCode: 1,
  signal: undefined,
  signalDescription: undefined,
  stdout: '',
  stderr: "'deno' is not recognized as an internal or external command,\r\n" +
    'operable program or batch file.',
  failed: true,
  timedOut: false,
  isCanceled: false,
  killed: false
}
No globalVersion or semver not satisfied. globalVersion: undefined, versionRange: ^1.37.0
Using cached Deno CLI from C:\Users\Anton\AppData\Roaming\netlify\Config\deno-cli\deno.exe
getBinaryVersion failed Error: Command failed with exit code 1: deno --version
'deno' is not recognized as an internal or external command,
operable program or batch file.
    at makeError (file:///C:/Users/Anton/AppData/Roaming/nvm/v18.17.0/node_modules/netlify-cli/node_modules/@netlify/edge-bundler/node_modules/execa/lib/error.js:59:11)
    at handlePromise (file:///C:/Users/Anton/AppData/Roaming/nvm/v18.17.0/node_modules/netlify-cli/node_modules/@netlify/edge-bundler/node_modules/execa/index.js:119:26)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async DenoBridge.getBinaryVersion (file:///C:/Users/Anton/AppData/Roaming/nvm/v18.17.0/node_modules/netlify-cli/node_modules/@netlify/edge-bundler/dist/node/bridge.js:49:32)
    at async DenoBridge.getGlobalBinary (file:///C:/Users/Anton/AppData/Roaming/nvm/v18.17.0/node_modules/netlify-cli/node_modules/@netlify/edge-bundler/dist/node/bridge.js:83:31)
    at async DenoBridge.getBinaryPath (file:///C:/Users/Anton/AppData/Roaming/nvm/v18.17.0/node_modules/netlify-cli/node_modules/@netlify/edge-bundler/dist/node/bridge.js:122:28)
    at async DenoBridge.run (file:///C:/Users/Anton/AppData/Roaming/nvm/v18.17.0/node_modules/netlify-cli/node_modules/@netlify/edge-bundler/dist/node/bridge.js:147:38)
    at async getFunctionConfig (file:///C:/Users/Anton/AppData/Roaming/nvm/v18.17.0/node_modules/netlify-cli/node_modules/@netlify/edge-bundler/dist/node/config.js:42:42)
    at async file:///C:/Users/Anton/AppData/Roaming/nvm/v18.17.0/node_modules/netlify-cli/node_modules/@netlify/edge-bundler/dist/node/bundler.js:80:86
    at async Promise.all (index 0) {
  shortMessage: 'Command failed with exit code 1: deno --version',
  command: 'deno --version',
  escapedCommand: 'deno --version',
  exitCode: 1,
  signal: undefined,
  signalDescription: undefined,
  stdout: '',
  stderr: "'deno' is not recognized as an internal or external command,\r\n" +
    'operable program or batch file.',
  failed: true,
  timedOut: false,
  isCanceled: false,
  killed: false
}
No globalVersion or semver not satisfied. globalVersion: undefined, versionRange: ^1.37.0
Using cached Deno CLI from C:\Users\Anton\AppData\Roaming\netlify\Config\deno-cli\deno.exe
No in-source config found for edge function at 'C:\source\next-js-netlify\nextjs\.netlify\edge-functions\___netlify-edge-handler-src-middleware\___netlify-edge-handler-src-middleware.js'
Edge Functions manifest: {"bundles":[{"asset":"0acff3bc4ccca0c19b2b3d80a8b7c8231a1a0002558c8419af264ad3abb78489.eszip","format":"eszip2"}],"routes":[{"function":"___netlify-edge-handler-src-middleware","pattern":"^(?:/(_next/data/[^/]{1,}))?(?:/((?!_next/)[^/.]{1,}))(|\\.json|/?index|/?index\\.json)?[/#\\?]?$","excluded_patterns":[]},{"function":"___netlify-edge-handler-src-middleware","pattern":"^(?:/(_next/data/[^/]{1,}))?(?:/((?!_next/)[^/.]{1,}))(?:/((?!api/|_next/|sitecore/api/|-/|[\\w-]+\\.\\w+).*))(.json)?[/#\\?]?$","excluded_patterns":[]}],"post_cache_routes":[],"bundler_version":"11.2.2","layers":[],"import_map":"netlify:import-map","function_config":{"___netlify-edge-handler-src-middleware":{"name":"Next.js Middleware Handler","generator":"@netlify/plugin-nextjs@5.0.0-beta.9"}}}

(Edge Functions bundling completed in 3.9s)
Build step duration: Edge Functions bundling completed in 3954ms

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


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


(@netlify/plugin-nextjs onEnd completed in 11ms)
Build step duration: @netlify/plugin-nextjs onEnd completed in 11ms

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


(options.onEnd completed in 3ms)
Build step duration: 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
      at PluginContext.failBuild (file:///C:/source/next-js-netlify/nextjs/node_modules/@netlify/plugin-nextjs/dist/esm-chunks/chunk-DWC6JSN7.js:167:29)
      at publishStaticDir (file:///C:/source/next-js-netlify/nextjs/node_modules/@netlify/plugin-nextjs/dist/esm-chunks/chunk-ZWFKLYLH.js:64:9)
      at async onPostBuild (file:///C:/source/next-js-netlify/nextjs/node_modules/@netlify/plugin-nextjs/dist/index.js:66:3)
      at async Object.run (file:///C:/Users/Anton/AppData/Roaming/nvm/v18.17.0/node_modules/netlify-cli/node_modules/@netlify/build/lib/plugins/child/run.js:25:5)
      at async handleEvent (file:///C:/Users/Anton/AppData/Roaming/nvm/v18.17.0/node_modules/netlify-cli/node_modules/@netlify/build/lib/plugins/child/main.js:28:42)
      at async process.<anonymous> (file:///C:/Users/Anton/AppData/Roaming/nvm/v18.17.0/node_modules/netlify-cli/node_modules/@netlify/build/lib/plugins/ipc.js:91:24)

Please be mindful of your tone. We don’t know that there are no more logs being produced that are visible on your system. You only shared this one line before:

Without any indication if that’s the only error message or if you excluded any useful error messages that existed before this. As someone who deals with multiple users sending incomplete and unhelpful log messages, I’m in no position to know if these were all the logs or if you had missed some part of logs that contained the actual error.

You could have simply said there’s nothing more to share instead of using quotes uncessarily. No need to be hostile. Maybe you didn’t intend to be, but that’s how your tone is being perceived from the receiving end.


In any case, this error comes from these lines in the code:

import { cp, mkdir, rename, rm } from 'node:fs/promises'
try {
    await rm(ctx.tempPublishDir, { recursive: true, force: true })
    await mkdir(ctx.tempPublishDir, { recursive: true })
    await rename(ctx.publishDir, ctx.tempPublishDir)
    await rename(ctx.staticDir, ctx.publishDir)
  } catch (error) {
    ctx.failBuild('Failed publishing static content', error instanceof Error ? { error } : {})
  }

Thus, any of those lines could be failing. Without knowing your setup or having your repo, this is not possible to guess or debug further.

Couple of things for you to try:

  • Try a more recent version: 5.0.0-rc.1
  • Ensure you’re using Next.js 13.5+
  • Share your repo or a minimal reproduction
  • Try building via Git on Netlify instead of the CLI

Please be mindful of your tone. We don’t know that there are no more logs being produced that are visible on your system. You only shared this one line before:

Sorry, but that was your tone. Not mine. You wrote about “highly unactionable piece of error message”. And I just repeated your words and explained that they should be related to your CLI and your plugin, but not to my message.

If you perceived repeating your words as hostile then probably something wrong is with your words, but not my reply.


But, never mind, I am here not to swear to each other.

I will try the things that you have suggested and let you know if it helps.