Node / Typescript - Cannot find module '/opt/render/project/src/dist/index.js

getting the following error

Nov 21 07:41:48 PM  Error: Cannot find module '/opt/render/project/src/dist/index.js'
Nov 21 07:41:48 PM      at Function.Module._resolveFilename (internal/modules/cjs/loader.js:885:15)
Nov 21 07:41:48 PM      at Function.Module._load (internal/modules/cjs/loader.js:730:27)
Nov 21 07:41:48 PM      at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
Nov 21 07:41:48 PM      at internal/main/run_main_module.js:17:47 {
Nov 21 07:41:48 PM    code: 'MODULE_NOT_FOUND',
Nov 21 07:41:48 PM    requireStack: []
Nov 21 07:41:48 PM  }

package.json

{
  "name": "bags_api_node",
  "version": "1.0.0",
  "description": "",
  "main": "dist/index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "build": "tsc",
    "start": "node dist/index.js"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "dotenv": "^16.3.1",
    "drizzle-orm": "^0.29.0",
    "express": "^4.18.2",
    "express-async-errors": "^3.1.1",
    "helmet": "^7.1.0",
    "mysql2": "^3.6.3"
  },
  "devDependencies": {
    "@types/express": "^4.17.21",
    "@types/node": "^20.9.0",
    "drizzle-kit": "^0.20.2",
    "ts-node": "^10.9.1",
    "typescript": "^5.2.2"
  }
}

build command: npm install && npm build
start command: node dist/index.js

any help appreciated

got it working with build command: npm install; npm run build

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