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.

intermittent: Cannot find module for page

See original GitHub issue

Bug report

Describe the bug

While running in dev mode (npm run dev), I get ‘{ Error: Cannot find module for page: /lessons/[album]/[slug]’. This happens occasionaly and I can’t reproduce it on demand.

Once it happens, the Error page will be displayed and then after a few seconds the page will be re-displayed without the error – rendered as it should be.

My page set up:

pages ->
   lessons ->
      [album] ->
         [slug].tsx

The page [slug].tsx indeeds exports all the necessary paths via getStaticPaths (e.g. [ .. {"params":{"album":"mlu","slug":"association-rules"}} .. ])

To Reproduce

I am unable to find a reliable way to demonstrate this on demand.

Expected behavior

Screenshots

Screen Shot 2020-08-04 at 12 10 08 PM

If applicable, add screenshots to help explain your problem.

System information

  • OS: mac/10.15.6
  • Version of Next.js: 9.5 (although I noticed this happening since 9.3)
  • Version of Node.js: 10.16.3

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

15reactions
alexkreidlercommented, Apr 22, 2021

For me, I had the yarn dev (next) command running in another terminal. Once I killed that process and ran yarn build && yarn export, the issue went away.

5reactions
nick-myers-dtcommented, Dec 23, 2020

I ran into this error today using next build:

info  - Creating an optimized production build  
info  - Compiled successfully

> Build error occurred
Error: Cannot find module for page: /accounts/create/[companyId]
    at pageNotFoundError (/Users/nickmyers/repos/rebuild/admin/node_modules/next/dist/next-server/server/require.js:1:384)
    at getPagePath (/Users/nickmyers/repos/rebuild/admin/node_modules/next/dist/next-server/server/require.js:1:917)
    at /Users/nickmyers/repos/rebuild/admin/node_modules/next/dist/build/index.js:15:3168
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async Promise.all (index 3)
    at async build (/Users/nickmyers/repos/rebuild/admin/node_modules/next/dist/build/index.js:15:2729) {
  code: 'ENOENT'
}

I ran next build again and it completed without issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nextjs export gives Cannot find module for page
I wanted to export the site with some dynamic routes. My pages folder structure is like below page locales [locale] [slug].js. When I...
Read more >
module-not-found - Next.js
A module not found error can occur for many different reasons: The module you're trying to import is not installed in your dependencies;...
Read more >
cannot find module [Node npm Error Solved] - freeCodeCamp
How to Fix the "cannot find module" Error · delete the node modules folder by running rm -rf node_modules · delete package.lock.json file...
Read more >
99 grand marquis pats module location. 99 +$45. Sales ...
If you still have any questions or concerns you can call our Ford Parts Specialists at 844-987-FORD and we'll help you find the...
Read more >
Suddenlink router init failed - La Bina Travel Designer
By continuing to use this site you consent to the use of cookies ... We can use this as follows:Cannot find module 'autoprefixer'...
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