Nodejs app in ts deployment error

im using onrender to deploy my nodejs application in ts

{
  "name": "mern",
  "version": "1.0.0",
  "description": "",
  "main": "server.js",
  "scripts": {
    "start": "node dist/server.js",
    "dev": "nodemon",
    "build": "tsc"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "cookie-parser": "1.4.6",
    "cors": "2.8.5",
    "date-fns": "2.30.0",
    "express": "4.18.2",
    "uuid": "9.0.0"
  },
  "devDependencies": {
    "@types/cookie-parser": "1.4.3",
    "@types/cors": "2.8.13",
    "@types/express": "4.17.17",
    "@types/node": "20.4.2",
    "@types/uuid": "9.0.2",
    "nodemon": "3.0.1",
    "ts-node": "10.9.1",
    "typescript": "5.1.6"
  }
}

this is my package json file but it throws an error

> mern@1.0.0 start /opt/render/project/src
Jul 16 05:19:49 PM  > node dist/server.js
Jul 16 05:19:49 PM  
Jul 16 05:19:49 PM  internal/modules/cjs/loader.js:888
Jul 16 05:19:49 PM    throw err;
Jul 16 05:19:49 PM    ^
Jul 16 05:19:49 PM  
Jul 16 05:19:49 PM  Error: Cannot find module '/opt/render/project/src/dist/server.js'
Jul 16 05:19:49 PM      at Function.Module._resolveFilename (internal/modules/cjs/loader.js:885:15)
Jul 16 05:19:49 PM      at Function.Module._load (internal/modules/cjs/loader.js:730:27)
Jul 16 05:19:49 PM      at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
Jul 16 05:19:49 PM      at internal/main/run_main_module.js:17:47 {
Jul 16 05:19:49 PM    code: 'MODULE_NOT_FOUND',
Jul 16 05:19:49 PM    requireStack: []
Jul 16 05:19:49 PM  }

is it because its missing the dev dependencies

Build command yarn

Start command : node app.js

Hi,

You’re not installing your dependencies:

  • Build Command: npm install && npm run build

  • Start Command: npm start

Alan

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