TypeScript Errors with Express and Missing Declarations on Render (SOLVED)

Hello,

I’m currently facing issues with deploying my Node.js application on Render that uses TypeScript and Express. I’ve encountered several errors related to missing type declarations, which prevent the application from compiling successfully.
I had no issues deploying previously with the same setup. But now I am getting these errors?

Solution

  • Remove env variable NODE_ENV= Your_Input
    Not sure why but seems like this created some sort of conflict among the deployment process.

What I tried

  • I have moved the dependencies over from dev.
  • Remove my node_modules and package lock and resinstalled everything.
  • Added the 3 dependencies from dev to dependency.

Here are the specific errors.

src/server.ts(6,21): error TS7016: Could not find a declaration file for module 'express'. '/opt/render/project/src/node_modules/express/index.js' implicitly has an 'any' type. Try npm i --save-dev @types/expressif it exists or add a new declaration (.d.ts) file containingdeclare module ‘express’;`

src/server.ts(7,26): error TS7016: Could not find a declaration file for module ‘cookie-parser’. ‘/opt/render/project/src/node_modules/cookie-parser/index.js’ implicitly has an ‘any’ type.
Try npm i --save-dev @types/cookie-parser if it exists or add a new declaration (.d.ts) file containing declare module 'cookie-parser';

src/server.ts(32,18): error TS7016: Could not find a declaration file for module ‘cors’.
‘/opt/render/project/src/node_modules/cors/lib/index.js’ implicitly has an ‘any’ type.
Try npm i --save-dev @types/cors if it exists or add a new declaration (.d.ts) file containing declare module 'cors';

Here is my package.json file.

{
“name”: “excelreader”,
“version”: “1.0.0”,
“main”: “index.js”,
“scripts”: {
“setup-project”: “npm i && cd client && npm i”,
“server”: “nodemon src/server.ts”,
“client”: “cd client && npm run dev”,
“dev”: “concurrently --kill-others-on-fail " npm run server" " npm run client"”,
“test-server”: “jest”,
“test-client”: “cd client && npm run test”,
“test”: “concurrently --kill-others-on-fail "npm run test-server" "npm run test-client"”
},
“keywords”: ,
“author”: “”,
“license”: “ISC”,
“description”: “”,
“dependencies”: {
“bcrypt”: “^5.1.1”,
“cookie-parser”: “^1.4.6”,
“cors”: “^2.8.5”,
“csv-parser”: “^3.0.0”,
“dotenv”: “^16.4.5”,
“express”: “^4.21.0”,
“jsonwebtoken”: “^9.0.2”,
“mongoose”: “^8.6.3”,
“multer”: “^1.4.5-lts.1”,
“nodemon”: “^3.0.3”,
“ts-node”: “^10.9.1”
},
“devDependencies”: {
“@types/bcrypt”: “^5.0.2”,
“@types/cookie-parser”: “^1.4.7”,
“@types/cors”: “^2.8.17”,
“@types/express”: “^4.17.21”,
“@types/jest”: “^29.5.13”,
“@types/jsonwebtoken”: “^9.0.7”,
“@types/multer”: “^1.4.12”,
“@types/node”: “^20.16.5”,
“@types/supertest”: “^6.0.2”,
“concurrently”: “^9.0.1”,
“jest”: “^29.7.0”,
“supertest”: “^7.0.0”,
“ts-jest”: “^29.2.5”,
“typescript”: “^5.6.2”
}
}

Hi,

It looks like your devDependencies may not be installed. This can happen if you’ve manually set NODE_ENV to production. Render will set this env var as part of the Node Native Runtime: https://docs.render.com/environment-variables#node It’s not set at build time, so that all devDependencies will be installed. It’s then set to production at runtime.