Hello, I am facing an issue while deploying my application on render which uses nodejs + typescript + mongodb.
First have a look into my files
Package.json file :
{
“name”: “backend”,
“version”: “1.0.0”,
“main”: “./dist/index.js”,
“type”: “module”,
“scripts”: {
“start”: “node dist/index.js”,
“watch”: “tsc -w”,
“build”: “tsc”,
“dev”: “npx tsx watch ./src/index.ts”
},
“author”: “”,
“license”: “ISC”,
“description”: “”,
“dependencies”: {
“bcryptjs”: “^2.4.3”,
“cookie-parser”: “^1.4.6”,
“cors”: “^2.8.5”,
“dotenv”: “^16.4.5”,
“express”: “^4.19.2”,
“firebase”: “^10.13.1”,
“jsonwebtoken”: “^9.0.2”,
“mongoose”: “^8.6.0”,
“multer”: “^1.4.5-lts.1”
},
“devDependencies”: {
“@types/bcryptjs”: “^2.4.6”,
“@types/cookie-parser”: “^1.4.7”,
“@types/cors”: “^2.8.17”,
“@types/express”: “^4.17.21”,
“@types/jsonwebtoken”: “^9.0.6”,
“@types/multer”: “^1.4.12”,
“tsx”: “^4.19.0”,
“typescript”: “^5.5.4”
}
}
tsconfig.json
{
“compilerOptions”: {
“target”: “ES2020”,
“module”: “NodeNext”,
“rootDir”: “src”,
“moduleResolution”: “NodeNext”,
“outDir”: “dist”,
“esModuleInterop”: true,
“forceConsistentCasingInFileNames”: true,
“strict”: true,
“skipLibCheck”: true,
“resolveJsonModule”: true,
“allowSyntheticDefaultImports”: true
},
“include”: [“src//*.ts", "src//*.d.ts”],
“exclude”: [“node_modules”, “dist”]
}
When I am trying to deploy my application, it fails. It gives me some error like this :
src/controllers/change.ts(1,49): 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.
Sep 1 03:35:18 PM Try npm i --save-dev @types/express
if it exists or add a new declaration (.d.ts) file containing declare module 'express';
Basically it is saying that there are no types present of the modules that i am using. But you can see in the package.json file that all the types are stored in the dev dependency. Please help me out. I have tried all things.
My build command on render is “npm install && npm run build”
Please help me. This is an assignment given to me post which i will have a offer. Please help me out.
Please please please !!!