0

I'm working on an API with Typescript and expressjs. It was running fine on DigitalOcean till now with the following configs.


{
  "name": "i_h",
  "version": "1.0.0",
  "main": "index.js",
  "author": "ParampreetR",
  "license": "MIT",
  "scripts": {
    "start": "npx ts-node index.ts",
    "dev": "npx nodemon index.ts",
    "compile": "npx tsc --outDir ./compiled -w --jsx",
    "live": "npx nodemon ./compiled/index.js"
  },
  "dependencies": {
    "@aws-sdk/client-s3": "^3.515.0",
    "@prisma/client": "5.7.1",
    "@types/morgan": "^1.9.9",
    "body-parser": "^1.20.2",
    "cookie-parser": "^1.4.6",
    "cors": "^2.8.5",
    "dotenv": "^16.3.1",
    "express": "^4.18.2",
    "express-session": "^1.17.3",
    "express-validator": "^7.0.1",
    "js-base64": "^3.7.6",
    "mongodb": "^6.3.0",
    "morgan": "^1.10.0",
    "multer": "^1.4.5-lts.1",
    "nodemailer": "^6.9.8",
    "paypal-rest-sdk": "^1.8.1",
    "string-sanitizer": "^2.0.2",
    "uuid": "^9.0.1",
    "xlsx": "^0.18.5"
  },
  "devDependencies": {
    "@types/body-parser": "^1.19.5",
    "@types/cookie-parser": "^1.4.7",
    "@types/cors": "^2.8.17",
    "@types/express": "^4.17.21",
    "@types/express-session": "^1.18.0",
    "@types/multer": "^1.4.11",
    "@types/node": "^20.10.5",
    "@types/nodemailer": "^6.4.14",
    "@types/paypal-rest-sdk": "^1.7.9",
    "@types/uuid": "^9.0.7",
    "prisma": "^5.8.0",
    "ts-node": "^10.9.2",
    "typescript": "^5.3.3"
  }
}

Suddenly today I got few errors regarding @types files not installed (although they are added in devDep.).

[2024-07-07 07:48:12] index.ts(1,21): error TS7016: Could not find a declaration file for module 'express'. '/workspace/node_modules/express/index.js' implicitly has an 'any' type.
[2024-07-07 07:48:12]   Try `npm i --save-dev @types/express` if it exists or add a new declaration (.d.ts) file containing `declare module 'express';`
[2024-07-07 07:48:12] index.ts(8,24): error TS7016: Could not find a declaration file for module 'body-parser'. '/workspace/node_modules/body-parser/index.js' implicitly has an 'any' type.
[2024-07-07 07:48:12]   Try `npm i --save-dev @types/body-parser` if it exists or add a new declaration (.d.ts) file containing `declare module 'body-parser';`
[2024-07-07 07:48:12] index.ts(10,21): error TS7016: Could not find a declaration file for module 'express-session'. '/workspace/node_modules/express-session/index.js' implicitly has an 'any' type.
[2024-07-07 07:48:12]   Try `npm i --save-dev @types/express-session` if it exists or add a new declaration (.d.ts) file containing `declare module 'express-session';`
[2024-07-07 07:48:12] index.ts(11,26): error TS7016: Could not find a declaration file for module 'cookie-parser'. '/workspace/node_modules/cookie-parser/index.js' implicitly has an 'any' type.
[2024-07-07 07:48:12]   Try `npm i --save-dev @types/cookie-parser` if it exists or add a new declaration (.d.ts) file containing `declare module 'cookie-parser';`
[2024-07-07 07:48:12] index.ts(12,18): error TS7016: Could not find a declaration file for module 'cors'. '/workspace/node_modules/cors/lib/index.js' implicitly has an 'any' type.
[2024-07-07 07:48:12]   Try `npm i --save-dev @types/cors` if it exists or add a new declaration (.d.ts) file containing `declare module 'cors';`
[2024-07-07 07:48:12] index.ts(15,25): error TS7016: Could not find a declaration file for module 'compression'. '/workspace/node_modules/compression/index.js' implicitly has an 'any' type.
[2024-07-07 07:48:12]   Try `npm i --save-dev @types/compression` if it exists or add a new declaration (.d.ts) file containing `declare module 'compression';`
[2024-07-07 07:48:12] routes/admin.ts(1,57): error TS7016: Could not find a declaration file for module 'express'. '/workspace/node_modules/express/index.js' implicitly has an 'any' type.
[2024-07-07 07:48:12]   Try `npm i --save-dev @types/express` if it exists or add a new declaration (.d.ts) file containing `declare module 'express';`

Also tried build:digitalocean script and few other tweaks but still not working. Now with few experiments my package.json looks like this

{
  "name": "i_b",
  "version": "1.0.0",
  "main": "index.js",
  "author": "ParampreetR",
  "license": "MIT",
  "scripts": {
    "start": "yarn build && yarn serve",
    "build": "yarn compile",
    "serve": "node compiled/index.js",
    "dev": "yarn run nodemon index.ts",
    "compile": "yarn run tsc",
    "live": "yarn run nodemon ./compiled/index.js"
  },
  "dependencies": {
    "@aws-sdk/client-s3": "^3.515.0",
    "@prisma/client": "5.7.1",
    "@types/morgan": "^1.9.9",
    "body-parser": "^1.20.2",
    "compression": "^1.7.4",
    "cookie-parser": "^1.4.6",
    "cors": "^2.8.5",
    "dotenv": "^16.3.1",
    "express": "^4.18.2",
    "express-session": "^1.17.3",
    "express-validator": "^7.0.1",
    "js-base64": "^3.7.6",
    "mongodb": "^6.3.0",
    "morgan": "^1.10.0",
    "multer": "^1.4.5-lts.1",
    "nodemailer": "^6.9.8",
    "paypal-rest-sdk": "^1.8.1",
    "prisma": "^5.8.0",
    "string-sanitizer": "^2.0.2",
    "typescript": "^5.3.3",
    "uuid": "^9.0.1",
    "xlsx": "^0.18.5"
  },
  "devDependencies": {
    "@types/compression": "^1.7.5",
    "@types/cookie-parser": "^1.4.7",
    "@types/cors": "^2.8.17",
    "@types/express": "^4.17.21",
    "@types/express-session": "^1.18.0",
    "@types/multer": "^1.4.11",
    "@types/nodemailer": "^6.4.15",
    "@types/paypal-rest-sdk": "^1.7.9",
    "@types/uuid": "^10.0.0",
    "ts-node": "^10.9.2"
  }
}

0