ERR_MODULE_NOT_FOUND: Cannot find module '/opt/render/project/src/api/config/db.js'

Why is the module not found error appearing when trying to deploy my application? Does anyone know how to solve this as I can’t find a solution.
I tried change the script start for node index.js of node --experimental-modules --es-module-specifier-resolution=node index.js, but, nothing work.

“scripts”: {
“test”: “echo "Error: no test specified" && exit 1”,
“start”: “node --experimental-modules --es-module-specifier-resolution=node index.js”,
“dev”: “nodemon index.js”
},

Repository link → GitHub - paulinha-19/api-link
OBS: Local the code work

Apr 11 08:33:46 PM  ==> Cloning from https://github.com/paulinha-19/api-link...
Apr 11 08:33:47 PM  ==> Checking out commit 5d0a3bf47f5d5f28c649ec31163b5ad3345a2114 in branch master
Apr 11 08:33:51 PM  ==> Running build command 'npm install'...
Apr 11 08:33:59 PM  
Apr 11 08:33:59 PM  > es5-ext@0.10.62 postinstall /opt/render/project/src/api/node_modules/es5-ext
Apr 11 08:33:59 PM  >  node -e "try{require('./_postinstall')}catch(e){}" || exit 0
Apr 11 08:33:59 PM  
Apr 11 08:33:59 PM  added 208 packages from 237 contributors and audited 209 packages in 7.341s
Apr 11 08:33:59 PM  
Apr 11 08:33:59 PM  31 packages are looking for funding
Apr 11 08:33:59 PM    run `npm fund` for details
Apr 11 08:33:59 PM  
Apr 11 08:33:59 PM  found 3 vulnerabilities (1 moderate, 2 critical)
Apr 11 08:33:59 PM    run `npm audit fix` to fix them, or `npm audit` for details
Apr 11 08:33:59 PM  ==> Generating container image from build. This may take a few minutes...
Apr 11 08:35:05 PM  ==> Uploading build...
Apr 11 08:35:34 PM  ==> Build uploaded in 22s
Apr 11 08:35:34 PM  ==> Build successful 🎉
Apr 11 08:35:34 PM  ==> Deploying...
Apr 11 08:37:58 PM  ==> Starting service with 'npm start'
Apr 11 08:38:01 PM  
Apr 11 08:38:01 PM  > api@1.0.0 start /opt/render/project/src/api
Apr 11 08:38:01 PM  > node --experimental-modules --es-module-specifier-resolution=node index.js
Apr 11 08:38:01 PM  
Apr 11 08:38:01 PM  internal/process/esm_loader.js:74
Apr 11 08:38:01 PM      internalBinding('errors').triggerUncaughtException(
Apr 11 08:38:01 PM                                ^
Apr 11 08:38:01 PM  
Apr 11 08:38:01 PM  Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/opt/render/project/src/api/config/db.js' imported from /opt/render/project/src/api/index.js
Apr 11 08:38:01 PM      at finalizeResolution (internal/modules/esm/resolve.js:265:11)
Apr 11 08:38:01 PM      at moduleResolve (internal/modules/esm/resolve.js:699:10)
Apr 11 08:38:01 PM      at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:810:11)
Apr 11 08:38:01 PM      at Loader.resolve (internal/modules/esm/loader.js:88:40)
Apr 11 08:38:01 PM      at Loader.getModuleJob (internal/modules/esm/loader.js:241:28)
Apr 11 08:38:01 PM      at ModuleWrap.<anonymous> (internal/modules/esm/module_job.js:56:40)
Apr 11 08:38:01 PM      at link (internal/modules/esm/module_job.js:55:36) {
Apr 11 08:38:01 PM    code: 'ERR_MODULE_NOT_FOUND'
Apr 11 08:38:01 PM  }
Apr 11 08:38:01 PM  npm ERR! code ELIFECYCLE
Apr 11 08:38:01 PM  npm ERR! errno 1
Apr 11 08:38:01 PM  npm ERR! api@1.0.0 start: `node --experimental-modules --es-module-specifier-resolution=node index.js`
Apr 11 08:38:01 PM  npm ERR! Exit status 1
Apr 11 08:38:01 PM  npm ERR!
Apr 11 08:38:01 PM  npm ERR! Failed at the api@1.0.0 start script.
Apr 11 08:38:01 PM  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Apr 11 08:38:01 PM  
Apr 11 08:38:01 PM  npm ERR! A complete log of this run can be found in:
Apr 11 08:38:01 PM  npm ERR!     /opt/render/.cache/_logs/2023-04-11T23_38_01_849Z-debug.log
Apr 11 08:38:12 PM  ==> Starting service with 'npm start'
Apr 11 08:38:15 PM  
Apr 11 08:38:15 PM  > api@1.0.0 start /opt/render/project/src/api
Apr 11 08:38:15 PM  > node --experimental-modules --es-module-specifier-resolution=node index.js
Apr 11 08:38:15 PM  
Apr 11 08:38:16 PM  internal/process/esm_loader.js:74
Apr 11 08:38:16 PM      internalBinding('errors').triggerUncaughtException(
Apr 11 08:38:16 PM                                ^
Apr 11 08:38:16 PM  
Apr 11 08:38:16 PM  Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/opt/render/project/src/api/config/db.js' imported from /opt/render/project/src/api/index.js
Apr 11 08:38:16 PM      at finalizeResolution (internal/modules/esm/resolve.js:265:11)
Apr 11 08:38:16 PM      at moduleResolve (internal/modules/esm/resolve.js:699:10)
Apr 11 08:38:16 PM      at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:810:11)
Apr 11 08:38:16 PM      at Loader.resolve (internal/modules/esm/loader.js:88:40)
Apr 11 08:38:16 PM      at Loader.getModuleJob (internal/modules/esm/loader.js:241:28)
Apr 11 08:38:16 PM      at ModuleWrap.<anonymous> (internal/modules/esm/module_job.js:56:40)
Apr 11 08:38:16 PM      at link (internal/modules/esm/module_job.js:55:36) {
Apr 11 08:38:16 PM    code: 'ERR_MODULE_NOT_FOUND'
Apr 11 08:38:16 PM  }
Apr 11 08:38:16 PM  npm ERR! code ELIFECYCLE
Apr 11 08:38:16 PM  npm ERR! errno 1
Apr 11 08:38:16 PM  npm ERR! api@1.0.0 start: `node --experimental-modules --es-module-specifier-resolution=node index.js`
Apr 11 08:38:16 PM  npm ERR! Exit status 1

HI,

That file doesn’t seem to exist in your repo:

Cannot find module '/opt/render/project/src/api/config/db.js'

Looking in the api folder of the repo you shared: https://github.com/paulinha-19/api-link/tree/master/api

There’s no config folder or db.js

Alan

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