Error: Cannot find module '../routes/userRoutes' - please Help!

Dear friends,
I keep getting the above error and no matter what I do I can’t get it to work. Can anyone please Help?!!

The project:

Here is the complete log:
==> Build successful :tada:
Oct 7 06:41:33 PM ==> Deploying…
Oct 7 06:42:01 PM ==> Starting service with ‘node dist/server.js’
Oct 7 06:42:06 PM internal/modules/cjs/loader.js:888
Oct 7 06:42:06 PM throw err;
Oct 7 06:42:06 PM ^
Oct 7 06:42:06 PM
Oct 7 06:42:06 PM Error: Cannot find module ‘…/routes/userRoutes’
Oct 7 06:42:06 PM Require stack:
Oct 7 06:42:06 PM - /opt/render/project/src/dist/server.js
Oct 7 06:42:06 PM at Function.Module._resolveFilename (internal/modules/cjs/loader.js:885:15)
Oct 7 06:42:06 PM at Function.Module._load (internal/modules/cjs/loader.js:730:27)
Oct 7 06:42:06 PM at Module.require (internal/modules/cjs/loader.js:957:19)
Oct 7 06:42:06 PM at require (internal/modules/cjs/helpers.js:88:18)
Oct 7 06:42:06 PM at Object. (/opt/render/project/src/dist/server.js:6:20)
Oct 7 06:42:06 PM at Module._compile (internal/modules/cjs/loader.js:1068:30)
Oct 7 06:42:06 PM at Object.Module._extensions…js (internal/modules/cjs/loader.js:1097:10)
Oct 7 06:42:06 PM at Module.load (internal/modules/cjs/loader.js:933:32)
Oct 7 06:42:06 PM at Function.Module._load (internal/modules/cjs/loader.js:774:14)
Oct 7 06:42:06 PM at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) {
Oct 7 06:42:06 PM code: ‘MODULE_NOT_FOUND’,
Oct 7 06:42:06 PM requireStack: [ ‘/opt/render/project/src/dist/server.js’ ]
Oct 7 06:42:06 PM }

Hi there,

Thanks for reaching out.

The error here seems to be pretty clear, you’re referencing a file that isn’t where it’s expected:

Error: Cannot find module ‘…/routes/userRoutes’

You’ll need to check that the paths to the file in the require is correct. For example, the correct path traversing, casing, file type, etc.

Hope that helps


1 Like

Thanks Alan!
According to the GitHub link attached it should be easy, I have tried variety of ways but none of them worked. On other project I have deployed I used “node dist/server.js” and it worked. Should I add another path to the routs as well? maybe I’m writing it wrong? Could you please direct me to the file according to the GitHub link? I’ll keep trying anyway…:slight_smile:

Are you still seeing the same error?

If you could share some details of the issue you are experiencing that may help us troubleshoot it with you, e.g. any other logs/errors/output, specific URLs, service name/ID, reproduction steps, etc. If you don’t want to share these details on the community forum, please feel free to raise a ticket with


Thanks Alan!
I’ll be happy to share all details:)
As I mentioned above The repo is:

Maybe the way the main folders are structured is somehow wrong? Can you please take a peek?
The error message as showed above.
On the app settings I use for the Build Command: “yarn” (and it seems to works cause I get “Build successful” message).
But for the Start Command I can’t get the correct command/path.
See pic attached:

On an other project I used “node dist/server.js” for the Start Command and it worked just fine.

We can’t support your code as every app is different, I’m not seeing a Render issue here. Just because commands work on other projects doesn’t mean they will work on all of them. You need to take more note of the errors that are being shown and work through them or search for the message appropriate.

On this occasion, as you seem completely stuck, I took a quick look at your repo, it seems a little messy, but a few points you should investigate:

  • You don’t seem to have a yarn.lock, but do seem to have a package-lock.json. This implies you use npm and not yarn locally. Match your local package manager. Build Command npm install

  • Your Node version was set to 14. This version is out of active support. You should probably look to upgrade to an actively supported version, e.g. 18.12.0 is the current LTS.

  • The dist/server.js doesn’t references other files correctly, e.g. require("./routes/userRoutes");. there is no routes folder under dist. And ../routes/userRoutes would be a TypeScript file, but there seems to be another dist in routes, so you would need ../routes/dist/userRoutes


1 Like

Thank you so much Alan:)
I’ll investigate these points you have kindly suggested, hope one of them will do the trick.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.