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

I am receiving the following error while trying to get my program to run on render:

Jan 7 07:30:17 PM ==> Cloning from GitHub - wazuu/cse341-node
Jan 7 07:30:17 PM ==> Checking out commit 3449b7fc6e105ee1a9b1d8975286251fce904471 in branch master
Jan 7 07:30:20 PM ==> Running build command ‘yarn’…
Jan 7 07:30:20 PM yarn install v1.22.5
Jan 7 07:30:21 PM info No lockfile found.
Jan 7 07:30:21 PM warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
Jan 7 07:30:21 PM [1/4] Resolving packages…
Jan 7 07:30:21 PM [2/4] Fetching packages…
Jan 7 07:30:22 PM [3/4] Linking dependencies…
Jan 7 07:30:22 PM [4/4] Building fresh packages…
Jan 7 07:30:22 PM success Saved lockfile.
Jan 7 07:30:22 PM Done in 1.67s.
Jan 7 07:30:22 PM ==> Generating container image from build. This may take a few minutes…
Jan 7 07:31:19 PM ==> Uploading build…
Jan 7 07:31:43 PM ==> Build uploaded in 20s
Jan 7 07:31:43 PM ==> Build successful :tada:
Jan 7 07:31:43 PM ==> Deploying…
Jan 7 07:31:52 PM ==> Starting service with ‘node index.js’
Jan 7 07:31:52 PM internal/modules/cjs/loader.js:888
Jan 7 07:31:52 PM throw err;
Jan 7 07:31:52 PM ^
Jan 7 07:31:52 PM
Jan 7 07:31:52 PM Error: Cannot find module ‘/opt/render/project/src/index.js’
Jan 7 07:31:52 PM at Function.Module._resolveFilename (internal/modules/cjs/loader.js:885:15)
Jan 7 07:31:52 PM at Function.Module._load (internal/modules/cjs/loader.js:730:27)
Jan 7 07:31:52 PM at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
Jan 7 07:31:52 PM at internal/main/run_main_module.js:17:47 {
Jan 7 07:31:52 PM code: ‘MODULE_NOT_FOUND’,
Jan 7 07:31:52 PM requireStack:
Jan 7 07:31:52 PM }
Jan 7 07:31:56 PM ==> Starting service with ‘node index.js’
Jan 7 07:31:56 PM internal/modules/cjs/loader.js:888
Jan 7 07:31:56 PM throw err;
Jan 7 07:31:56 PM ^
Jan 7 07:31:56 PM
Jan 7 07:31:56 PM Error: Cannot find module ‘/opt/render/project/src/index.js’
Jan 7 07:31:56 PM at Function.Module._resolveFilename (internal/modules/cjs/loader.js:885:15)
Jan 7 07:31:56 PM at Function.Module._load (internal/modules/cjs/loader.js:730:27)
Jan 7 07:31:56 PM at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
Jan 7 07:31:56 PM at internal/main/run_main_module.js:17:47 {
Jan 7 07:31:56 PM code: ‘MODULE_NOT_FOUND’,
Jan 7 07:31:56 PM requireStack:
Jan 7 07:31:56 PM }
Jan 7 07:32:13 PM ==> Starting service with ‘node index.js’
Jan 7 07:32:13 PM internal/modules/cjs/loader.js:888
Jan 7 07:32:13 PM throw err;
Jan 7 07:32:13 PM ^
Jan 7 07:32:13 PM
Jan 7 07:32:13 PM Error: Cannot find module ‘/opt/render/project/src/index.js’
Jan 7 07:32:13 PM at Function.Module._resolveFilename (internal/modules/cjs/loader.js:885:15)
Jan 7 07:32:13 PM at Function.Module._load (internal/modules/cjs/loader.js:730:27)
Jan 7 07:32:13 PM at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
Jan 7 07:32:13 PM at internal/main/run_main_module.js:17:47 {
Jan 7 07:32:13 PM code: ‘MODULE_NOT_FOUND’,
Jan 7 07:32:13 PM requireStack:
Jan 7 07:32:13 PM }
Jan 7 07:32:48 PM ==> Starting service with ‘node index.js’
Jan 7 07:32:48 PM internal/modules/cjs/loader.js:888
Jan 7 07:32:48 PM throw err;
Jan 7 07:32:48 PM ^
Jan 7 07:32:48 PM
Jan 7 07:32:48 PM Error: Cannot find module ‘/opt/render/project/src/index.js’
Jan 7 07:32:48 PM at Function.Module._resolveFilename (internal/modules/cjs/loader.js:885:15)
Jan 7 07:32:48 PM at Function.Module._load (internal/modules/cjs/loader.js:730:27)
Jan 7 07:32:48 PM at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
Jan 7 07:32:48 PM at internal/main/run_main_module.js:17:47 {
Jan 7 07:32:48 PM code: ‘MODULE_NOT_FOUND’,
Jan 7 07:32:48 PM requireStack:
Jan 7 07:32:48 PM }
Jan 7 07:33:33 PM ==> Starting service with ‘node index.js’
Jan 7 07:33:33 PM internal/modules/cjs/loader.js:888
Jan 7 07:33:33 PM throw err;
Jan 7 07:33:33 PM ^
Jan 7 07:33:33 PM
Jan 7 07:33:33 PM Error: Cannot find module ‘/opt/render/project/src/index.js’
Jan 7 07:33:33 PM at Function.Module._resolveFilename (internal/modules/cjs/loader.js:885:15)
Jan 7 07:33:33 PM at Function.Module._load (internal/modules/cjs/loader.js:730:27)
Jan 7 07:33:33 PM at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
Jan 7 07:33:33 PM at internal/main/run_main_module.js:17:47 {
Jan 7 07:33:33 PM code: ‘MODULE_NOT_FOUND’,
Jan 7 07:33:33 PM requireStack:
Jan 7 07:33:33 PM }
Jan 7 07:35:11 PM ==> Starting service with ‘node index.js’
Jan 7 07:35:11 PM internal/modules/cjs/loader.js:888
Jan 7 07:35:11 PM throw err;
Jan 7 07:35:11 PM ^
Jan 7 07:35:11 PM
Jan 7 07:35:11 PM Error: Cannot find module ‘/opt/render/project/src/index.js’
Jan 7 07:35:11 PM at Function.Module._resolveFilename (internal/modules/cjs/loader.js:885:15)
Jan 7 07:35:11 PM at Function.Module._load (internal/modules/cjs/loader.js:730:27)
Jan 7 07:35:11 PM at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
Jan 7 07:35:11 PM at internal/main/run_main_module.js:17:47 {
Jan 7 07:35:11 PM code: ‘MODULE_NOT_FOUND’,
Jan 7 07:35:11 PM requireStack:
Jan 7 07:35:11 PM }
Jan 7 07:37:02 PM ==> Starting service with ‘node index.js’
Jan 7 07:37:02 PM internal/modules/cjs/loader.js:888
Jan 7 07:37:02 PM throw err;
Jan 7 07:37:02 PM ^
Jan 7 07:37:02 PM
Jan 7 07:37:02 PM Error: Cannot find module ‘/opt/render/project/src/index.js’
Jan 7 07:37:02 PM at Function.Module._resolveFilename (internal/modules/cjs/loader.js:885:15)
Jan 7 07:37:02 PM at Function.Module._load (internal/modules/cjs/loader.js:730:27)
Jan 7 07:37:02 PM at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
Jan 7 07:37:02 PM at internal/main/run_main_module.js:17:47 {
Jan 7 07:37:02 PM code: ‘MODULE_NOT_FOUND’,
Jan 7 07:37:02 PM requireStack:
Jan 7 07:37:02 PM }
Jan 7 07:37:07 PM ==> Starting service with ‘node index.js’
Jan 7 07:37:07 PM internal/modules/cjs/loader.js:888
Jan 7 07:37:07 PM throw err;
Jan 7 07:37:07 PM ^
Jan 7 07:37:07 PM
Jan 7 07:37:07 PM Error: Cannot find module ‘/opt/render/project/src/index.js’
Jan 7 07:37:07 PM at Function.Module._resolveFilename (internal/modules/cjs/loader.js:885:15)
Jan 7 07:37:07 PM at Function.Module._load (internal/modules/cjs/loader.js:730:27)
Jan 7 07:37:07 PM at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
Jan 7 07:37:07 PM at internal/main/run_main_module.js:17:47 {
Jan 7 07:37:07 PM code: ‘MODULE_NOT_FOUND’,
Jan 7 07:37:07 PM requireStack:
Jan 7 07:37:07 PM }
Jan 7 07:37:21 PM ==> Starting service with ‘node index.js’
Jan 7 07:37:22 PM internal/modules/cjs/loader.js:888
Jan 7 07:37:22 PM throw err;
Jan 7 07:37:22 PM ^
Jan 7 07:37:22 PM
Jan 7 07:37:22 PM Error: Cannot find module ‘/opt/render/project/src/index.js’
Jan 7 07:37:22 PM at Function.Module._resolveFilename (internal/modules/cjs/loader.js:885:15)
Jan 7 07:37:22 PM at Function.Module._load (internal/modules/cjs/loader.js:730:27)
Jan 7 07:37:22 PM at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
Jan 7 07:37:22 PM at internal/main/run_main_module.js:17:47 {
Jan 7 07:37:22 PM code: ‘MODULE_NOT_FOUND’,
Jan 7 07:37:22 PM requireStack:
Jan 7 07:37:22 PM }

Hey there :slight_smile:

Are you using yarn or npm? There is an error message saying it found package-lock.json that is used by npm, but the build command is yarn.

Try changing your build command to npm ci

Bergur

I am using yarn for this. I will try switching and see if that works. Thank you!

Ah ok, then there is no need to switch. How is your setup, where is the index.js file located? In the root of your project/repo?

Linux systems are case-sensitive, do the filename match or is it for example Index.js vs index.js?

Ya, I ended up figuring out just a little while ago. I had a couple of words spelt incorrectly, part of my format was incorrect, and names didn’t match up. With all of that fixed, it works now.

Thank you for your help.