Skip to content

Error: Cannot find module on ISR when using dynamic imports #209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
zomars opened this issue Apr 9, 2021 · 13 comments · Fixed by #294
Closed

Error: Cannot find module on ISR when using dynamic imports #209

zomars opened this issue Apr 9, 2021 · 13 comments · Fixed by #294
Labels
priority: medium type: bug code to address defects in shipped code

Comments

@zomars
Copy link

zomars commented Apr 9, 2021

Describe the bug

Using Incremental Static Regeneration seems to be breaking when using dynamic imported components.

To Reproduce
Steps to reproduce the behavior:

  1. Make a page that uses getStaticProps and getStaticPaths
  2. Add a dynamic component using next/dynamic
  3. Enable revalidate: 1 in getStaticProps
  4. See error

Expected behavior

It is expected to show the pre-rendered paged, instead I get this error:

Here's the error output:
{
  "errorType": "Runtime.UnhandledPromiseRejection",
  "errorMessage": "Error: Cannot find module '../../chunks/886.4ea9d7ad9b7228e07a29.js'\nRequire stack:\n- /var/task/src/netlify/functions/next_pages_slug/nextPage/index.js\n- /var/task/src/netlify/functions/next_pages_slug/renderNextPage.js\n- /var/task/src/netlify/functions/next_pages_slug/next_pages_slug.js\n- /var/task/next_pages_slug.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
  "trace": [
    "Runtime.UnhandledPromiseRejection: Error: Cannot find module '../../chunks/886.4ea9d7ad9b7228e07a29.js'",
    "Require stack:",
    "- /var/task/src/netlify/functions/next_pages_slug/nextPage/index.js",
    "- /var/task/src/netlify/functions/next_pages_slug/renderNextPage.js",
    "- /var/task/src/netlify/functions/next_pages_slug/next_pages_slug.js",
    "- /var/task/next_pages_slug.js",
    "- /var/runtime/UserFunction.js",
    "- /var/runtime/index.js",
    "    at process.<anonymous> (/var/runtime/index.js:35:15)",
    "    at process.emit (events.js:314:20)",
    "    at processPromiseRejections (internal/process/promises.js:209:33)",
    "    at processTicksAndRejections (internal/process/task_queues.js:98:32)"
  ]
}

Versions

  • Next.js: latest
  • plugin (if installed at fixed version): @netlify/plugin-nextjs
@lindsaylevine
Copy link

@zomars hey! can i see your package.json and netlify.toml if you have one? links to your site's build/deploy logs would also be great!

@lindsaylevine lindsaylevine added type: bug code to address defects in shipped code priority: medium labels Apr 9, 2021
@zomars
Copy link
Author

zomars commented Apr 9, 2021

Sure @lindsaylevine !

Here's a deployed url of the previous commit:

https://app.netlify.com/sites/jobsite-contentful/deploys/607095a7c76a4b00085000e7

And here's the one with revalidate enabled:

https://app.netlify.com/sites/jobsite-contentful/deploys/60709a6453e83a0007e5f78d

Here's my netlify.toml:

[build]
  command = "next build"
  functions = "netlify/functions"
  publish = "out"

And my relevant dependencies in package.json:

"next": "latest",
"react": "^17.0.2",
"react-dom": "^17.0.2",

@lindsaylevine
Copy link

@zomars ahh apologies! for build/deploy logs i meant a url that looks like: https://app.netlify.com/sites/{yoursitename}/deploys/60627d070f34e32724df2f89

i'm pretty sure i know what's going on already though :( related to next's recent webpack change. this was the previous bug netlify/next-on-netlify#121 - notice it's looking one directory up whereas your error is looking two directories up 🤦 . we'll figure it out though!

@zomars
Copy link
Author

zomars commented Apr 9, 2021

@lindsaylevine my bad! I've updated the above urls. Thank you for your time! 🙏

@lindsaylevine lindsaylevine changed the title Error: Cannot find module on ISR Error: Cannot find module on ISR when using dynamic imports Apr 10, 2021
@zomars
Copy link
Author

zomars commented Apr 14, 2021

@lindsaylevine Is there a known work around I could use? Maybe downgrading webpack? Or disabling ISR altogether in the mean time?

@lindsaylevine
Copy link

@zomars i think you could downgrade next to the last major release?

@zomars
Copy link
Author

zomars commented Apr 14, 2021

@lindsaylevine that would be from 10 to 9?

@lindsaylevine
Copy link

ahh my bad i should have been more specific! @zomars "major" release wasn't a good answer; in my head i meant "working" release 😅 . the breaking webpack change in next.js went out in https://github.com/vercel/next.js/releases/tag/v10.0.9 so <= 10.0.8 should work for you?

@Nexum
Copy link

Nexum commented May 5, 2021

I encountered the same problem with the new odb build :(
maybe this helps, i was on the verge of creating my own issue for this but i rather add to this one 👍

https://github.com/Nexum/netlify-plugin-nextjs-odb-dynamic-bug

Live Demo
https://netlify-plugin-nextjs-odb-dynamic-bug.netlify.app/

@zomars
Copy link
Author

zomars commented May 13, 2021

Awesome @lindsaylevine ! It this available now to deploy?

@lindsaylevine
Copy link

@zomars good question! in theory we shouldnt close the issue until its actually deployed/released (vs when it gets merged). this will go out in our next release. i can make sure it goes out by EOD tomorrow :)

@zomars
Copy link
Author

zomars commented May 14, 2021

Thanks you for the response!

@lindsaylevine
Copy link

@zomars this should be out now in 3.3.0!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: medium type: bug code to address defects in shipped code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants