I’m trying to deploy my Node.js + TypeScript project on Render.com, but I’m encountering several TypeScript build errors that I don’t see locally. The errors are mostly about missing modules and type definitions. Here are some of the errors I’m getting:
src/routers/mock/mock.ts(14,33): error TS2503: Cannot find namespace 'NodeJS'.
src/routers/mock/mock.ts(28,19): error TS2339: Property 'mock_settings' does not exist on type 'IOngoingJob'.
src/routers/mock/mock.ts(32,42): error TS2339: Property 'started_at' does not exist on type 'IOngoingJob'.
src/routers/ongoing-jobs-state.ts(1,61): error TS2307: Cannot find module 'express' or its corresponding type declarations.
src/routers/ongoing-jobs.ts(1,61): error TS2307: Cannot find module 'express' or its corresponding type declarations.
Everything works perfectly fine locally. Here's a snippet of my package.json:
{
"name": "roro-fume-api",
"version": "1.0.0",
"description": "",
"main": "dist/index.js",
"scripts": {
"build": "tsc",
"start": "node ./dist/index.js",
"dev": "ts-node-dev --respawn --transpile-only ./src/index.ts"
},
"author": "Yanay",
"license": "ISC",
"dependencies": {
"cors": "^2.8.5",
"dotenv": "^16.3.1",
"exceljs": "^4.4.0",
"express": "^4.18.2",
"mongodb": "^5.7.0",
"mongoose": "^7.4.1",
"roro-fume": "^0.0.29",
"socket.io": "^4.7.2"
},
"devDependencies": {
"@types/cors": "^2.8.13",
"@types/express": "^4.17.21",
"@types/mongodb": "^4.0.7",
"@types/node": "^20.12.12",
"nodemon": "^3.0.1",
"ts-node": "^10.9.1",
"tsc-alias": "^1.8.10",
"typescript": "^5.4.5"
}
}
And here’s my tsconfig.json:
{
"include": ["src/**/*"],
"exclude": ["node_modules"],
"compilerOptions": {
"target": "es2016",
"module": "commonjs",
"outDir": "./dist",
"rootDir": "./src",
"strict": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"typeRoots": ["./node_modules/@types", "./types"],
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"lib": ["es2020", "esnext.asynciterable", "dom"]
}
}
Local Development: Works perfectly with no issues.
Deployment Environment: Render.com.
Why might TypeScript be unable to find modules and type declarations on Render.com but not locally?
Are there any additional configurations or steps I should take to ensure the build works on Render.com?
Any insights or suggestions would be greatly appreciated!