Hello I recently migrated my app from a create-react-app to nextjs. I have installed the Essential Next.js by netlify plugin for my project. However I’m unsure if I have structured my project correctly.
I have tried deploying the app today but am seeing an error when I navigate to the root page. There are no build errors but the error on the deployed app is:
{
"errorType": "Runtime.ImportModuleError",
"errorMessage": "Error: Cannot find module 'request'\nRequire stack:\n- /var/task/src/netlify/functions/next_index/nextPage/index.js\n- /var/task/src/netlify/functions/next_index/renderNextPage.js\n- /var/task/src/netlify/functions/next_index/next_index.js\n- /var/task/next_index.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
"trace": [
"Runtime.ImportModuleError: Error: Cannot find module 'request'",
"Require stack:",
"- /var/task/src/netlify/functions/next_index/nextPage/index.js",
"- /var/task/src/netlify/functions/next_index/renderNextPage.js",
"- /var/task/src/netlify/functions/next_index/next_index.js",
"- /var/task/next_index.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: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"
]
}
Welcome to the Netlify Forums Thanks for sharing these details.
Before we dive in further, can you share your Netlify site id with us, as well as your github repo if it is public? Additionally, have you taken any other debugging steps since posting this four days ago?
Hi Jen, No it isn’t in my package.json, the only reference I can find of it in the project is in my package-lock.json as a dependency of the microsoft-signalr package.
Please tell me if that’s incorrect but I didn’t think I needed dependencies directly in my package.json.
Edit: If it’s of any use, I import the @microsoft/signalr package in my /pages/index.js file and connect to a hub via WebSockets in a useEffect React hook.
Hey @Huweey,
Ah, we use the package.json to know what dependencies to install in the build container for your build. Given the error you’re seeing, I’d try adding request to the package.json, triggering another build, and seeing what happens- I’ll be curious if you then get similar errors about missing the ws module so please let us know how it goes.
I have taken this to some of our Nextjs experts, and there are two next steps here.
We will need a public repo we can follow so that we can reproduce this. You can create a new repo and share it in this thread. Would you be open to this?
You can try esbuild via [functions] node_bundler = "esbuild"
Sorry to hear you are encountering obstacles. Can you share your site URL and your repo please? Additionally, can you share what debugging steps you have taken?
But like, my app is a little big right now, I’ve already tried to just update the version on the package.json (from 11.0.0 to 12.0.0) but it seems to cause a lot of bugs in the app, so it’s something that needs to be updated in others parts of the code (read the next update documentation etc)…
Well… It’s need time and not all kind of application can have this update… So maybe I will wait for an resolution of netlify engineers <3