Error: Cannot find module '/opt/render/project/dist/src/index.js'

If you’re seeing…

Error: Cannot find module '/opt/render/project/src/dist/src/index.js'

…the files aren’t where your structure diagram shows them. You can ignore the /opt/render/project/src part of the path. That is controlled by Render and is where your repo is cloned into.

So within your file structure dist/src/index.js isn’t being found. Either the path is incorrect, or maybe the built files have a different casing. Render uses Linux with a case-sensitive filesystem, so filepaths need to match the case exactly.

You could maybe debug it with a simple temporary addition to your Build Command, e.g.:

<your current build command> && ls dist

Which will list the structure of your dist folder into the deploy logs, or fail if it’s not there.

Alan

2 Likes