I can´t deploy my node-express api

Im trying to deploy an express-node api. I already setting al the enviroment variables and the node version but i have this problem (sorry my first lenguage is spanish).

Error: Cannot find module '/opt/render/project/src/index.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1039:15)
    at Module._load (node:internal/modules/cjs/loader:885:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47 {
  requireStack: []

My package.json
“name”: “api”,
“version”: “1.0.0”,
“description”: “api”,
“main”: “index.js”,
“type”: “module”,
“scripts”: {
“build”: “node src --out-dir dist”,
“start”: “node dist/index.js”,
“dev”: “nodemon src/index.js”

REPO:GitHub - ZoeBarrios/API_NODE: API desarrollada para la aplicación Adoptando Sonrisas.


There isn’t an index.js in the root of the repo you linked. There’s an app.js and there’s an index.js in the src folder.

You’ll need to check you’re correctly referencing the file you want to start.


I try changing root directory to ./src but the only start command that don’t throw error is npm run dev. Maybe src is setting automatic.

Your package.json is in the root of your repo, so if you set the root directory to src that might cause issues.

Maybe trying removing the Root Directory and just call index.js directly in your Start Command, e.g.:

node ./src/index.js


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