question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot find module '/.next/server/pages/_error.js'

See original GitHub issue

Verify canary release

  • I verified that the issue exists in Next.js canary release

Provide environment information

Operating System: Platform: linux Arch: x64 Version: #45~20.04.1-Ubuntu SMP Mon Apr 4 09:38:31 UTC 2022 Binaries: Node: 16.14.2 npm: 8.5.0 Yarn: 1.22.17 pnpm: N/A Relevant packages: next: 12.1.5 react: 17.0.2 react-dom: 17.0.2

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

I get this issue from sentry in production. Is there a way to fix this?

Error: Cannot find module '/home/panel/panel/.next/server/pages/_error.js'
Require stack:
- /home/panel/panel/node_modules/next/dist/server/require.js
- /home/panel/panel/node_modules/next/dist/server/next-server.js
- /home/panel/panel/node_modules/next/dis...
  File "node:internal/modules/cjs/loader", line 933, col 15, in Module._resolveFilename
  File "/home/panel/panel/node_modules/next/dist/build/webpack/require-hook.js", line 183, col 28, in Function.mod._resolveFilename
    return resolveFilename.call(mod, request, parent, isMain, options);
  File "node:internal/modules/cjs/loader", line 778, col 27, in Module._load
  File "node:internal/modules/cjs/loader", line 1005, col 19, in Module.require
  File "node:internal/modules/cjs/helpers", line 102, col 18, in require
  File "/home/panel/panel/node_modules/next/dist/server/require.js", line 47, col 12, in Object.requirePage
    return require(pagePath);
  File "/home/panel/panel/node_modules/next/dist/server/load-components.js", line 58, col 23, in Object.loadComponents
    (0, _require).requirePage(pathname, distDir, serverless),
  File "/home/panel/panel/node_modules/next/dist/server/next-server.js", line 444, col 63, in NextNodeServer.findPageComponents
    const components = await (0, _loadComponents).loadComponents(this.distDir, pagePath, !this.renderOpts.dev && this._isLikeSer {snip}
  File "/home/panel/panel/node_modules/@sentry/nextjs/dist/utils/instrumentServer.js", line 223, col 55, in NextNodeServer.<anonymous>
    return [2 /*return*/, origMethod.call.apply(origMethod, tslib_1.__spread([this, parameterizedPath], args))];
  File "/home/panel/panel/node_modules/tslib/tslib.js", line 141, col 27, in step
    op = body.call(thisArg, _);

Expected Behavior

Not getting this issue.

To Reproduce

Nothing.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
timneutkenscommented, May 3, 2022

You can check the upgrading guide, it covers this exact case: https://nextjs.org/docs/upgrading#cleaning-the-distdir-is-now-a-default

1reaction
timneutkenscommented, May 14, 2022

As said you can disable removing the distDir using the flag as per the upgrade guide 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: Cannot find module '.next\server\pages-manifest.json ...
I had this issue. I had a _document.js file and was doing things with styled-components but didn't actually have the styled components package ......
Read more >
Getting `Cannot find module '.next\server\pages-manifest.json ...
js . When I remove this file, everything works fine. As soon as I add the babel.config.js file, I get this error
Read more >
r/nextjs - Reddit
NextJS throws random "Error: Cannot find module './undefined'". I just encountered this error while navigating to different links using NextJs's ...
Read more >
Cannot find module '/user_code/next/server/pages-manifest ...
Error : Cannot find module '/user_code/next/server/pages-manifest.json'
Read more >
GabZanMacaw - Netlify Support Forums
... /var/runtime/UserFunction.js\n- /var/runtime/index.js", "trace": [ "Error: Cannot find module '/var/task/.next/server/middleware-manifest.json'", ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found