Home
Support Forums

Module import error

Hi,

I’m working on a nextJS site that is currently deployed to Netlify and has been working well. However, when trying to create preview deploy for some changes that utilise the module ‘three’ we’re getting the following module import error at runtime (after a successful build).

{
"errorType": "Runtime.ImportModuleError",
"errorMessage": "Error: Cannot find module 'three'",
"trace": [
"Runtime.ImportModuleError: Error: Cannot find module 'three'",
"    at _loadUserApp (/var/runtime/UserFunction.js:100:13)",
"    at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)",
"    at Object.<anonymous> (/var/runtime/index.js:43:30)",
"    at Module._compile (internal/modules/cjs/loader.js:999:30)",
"    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)",
"    at Module.load (internal/modules/cjs/loader.js:863:32)",
"    at Function.Module._load (internal/modules/cjs/loader.js:708:14)",
"    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)",
"    at internal/main/run_main_module.js:17:47"
]
}

I have tested running the build on other environments and am not able to reproduce the issue. Any advice would be greatly appreciated.

Hey there, @martinseanhunt :wave:

Welcome to the Netlify Forums!

Can you share your Netlify site as well as a public repo with us? Thank you :slight_smile:

Hi Hillary, unfortunately the repo isn’t public but here’s the review deploy in question https://deploy-preview-2--cardano-summit.netlify.app/

Hi there, @martinseanhunt :wave:

Thanks for your patience. I see that Jen has been supporting you in the Helpdesk. Please feel free to follow up there if you have any further questions.

For any future Forums members who are following along, this was the suggestion from our Support Engineer:

It may be worth trying to bundle with esbuild instead of our default functions bundler. You can do that by adding this block to your netlify.toml:

[functions]
  node_bundler = "esbuild"