Home
Support Forums

Gatsby 4 - Runtime.ImportModuleError on 404 pages

Hello everyone,

My Netlify site name is thirdfort-marketing-internal

I just upgraded to Gatsby 4 (and integrated Prismic headless CMS as part of the process) but unfortunately I’m getting a bug when previewing my Pull Request.

The build is successful and existing pages work great, but if I go to a non-existent page (Eg https://deploy-preview-21--thirdfort-marketing-internal.netlify.app/does-not-exist) I get the following message

{
"errorType": "Runtime.ImportModuleError",
"errorMessage": "Error: Cannot find module '/var/task/.cache/page-ssr'\nRequire stack:\n- /var/task/.netlify/functions-internal/__dsg/__dsg.js\n- /var/task/__dsg.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
"trace": [
"Runtime.ImportModuleError: Error: Cannot find module '/var/task/.cache/page-ssr'",
"Require stack:",
"- /var/task/.netlify/functions-internal/__dsg/__dsg.js",
"- /var/task/__dsg.js",
"- /var/runtime/UserFunction.js",
"- /var/runtime/index.js",
"    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:1072:14)",
"    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)",
"    at Module.load (internal/modules/cjs/loader.js:937:32)",
"    at Function.Module._load (internal/modules/cjs/loader.js:778:12)",
"    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)",
"    at internal/main/run_main_module.js:17:47"
]
}

The annoying thing is that I’m not using any functions or DSG pages. It seems that the error is coming from there. Is there a way to fix this or disable the functions altogether?

I’m using the correct ENV for my builds so it supports Gatsby 4

NODE_VERSION
14

AWS_LAMBDA_JS_RUNTIME
nodejs14.x

Goal is to:

  • get the 404 page if I go to a page that doesn’t exist
  • be able to preview Prismic pages that are in draft (not live yet).

Anything that could help will be amazing - I’ve tried pretty much anything I can think of but there isn’t much info online about it.

Thanks,
Kris

Hey,

Just wanted to check if there are any updates on this? At the moment, this is a big blocker to me merging the branch so I might need to do downgrade to Gatsby 3 before doing so.

Thanks,
Kris

Hey @kb1995,

Since you’re not using any DSG, I’m assuming it’s a fully static export? In that case, would it be possible for you to try uninstall the build plugin auto-installed by Netlify and give it a try?

@hrishikesh

Where can I find the build plugin which is auto installed by Netlify?

The only plugin which is currently present is the “Essential Gatsby” plugin.

@hrishikesh Update:

I disabled the Essential Gatsby plugin, and that seems to have fixed the problem.

However, my build times now take a lot longer and have some of these warning messages:

5:39:08 PM: warning Query takes too long:
5:39:08 PM: File path: /opt/build/repo/src/pages/estate-agents.tsx
5:39:08 PM: URL path: /estate-agents/
5:39:08 PM: warning Query takes too long:
5:39:08 PM: File path: /opt/build/repo/src/pages/for-lawyers.tsx
5:39:08 PM: URL path: /for-lawyers/
5:39:08 PM: warning Query takes too long:
5:39:08 PM: File path: /opt/build/repo/src/pages/index.tsx
5:39:08 PM: URL path: /
5:39:08 PM: warning Query takes too long:
5:39:08 PM: File path: /opt/build/repo/src/pages/partnerships.tsx
5:39:08 PM: URL path: /partnerships/

I guess we can’t do anything about that until the Essential Plugin supports Gatsby 4?

Well, it’s good to know that the 404 page’s errors have been fixed. I would have assumed that Essential Gatsby Plugin would not change anything for purely static websites.

Could you try the Beta version, if you haven’t already: GitHub - netlify/netlify-plugin-gatsby: A build plugin to integrate Gatsby seamlessly with Netlify?

Hey, I had the beta version installed. So that’s probably something to report over to the team responsible for the plugin

Alright then, I’ll discuss this with the devs and get back to you with an update.

Hey @kb1995,

Sorry for the delay here, it appears to be a bug and the team is looking into it.

Meanwhile, the devs said that since you’re not using DSG, you should be fine with the non-beta version of the plugin as that’s not supposed to handle DSG.

Would you please give that a try?

1 Like

I had this exact issue. Not using DSG, but had followed instructions here:

Only difference is I had to use

npm install -D @netlify/plugin-gatsby@^2.0.0-zz-beta.0

in order to install the beta package. (just picked the most likely one)

But still got the same error as OP until I downgraded to the non-beta 1.3.0 version. And now 404 pages deliver correctly. Woohoo!

1 Like