In nest js I am facing issue for npm run dev. My machine is windows machine.
Cannot find type definition file for 'cron'.
{
"name": "my-api",
"version": "0.0.1",
"description": "",
"author": "",
"private": true,
"license": "UNLICENSED",
"engines": {
"node": ">=16.0.0",
"npm": ">= 8.0",
"yarn": "please-use-npm"
},
"scripts": {
"build": "TZ=UTC nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "NODE_ENV=development TZ=UTC nest start",
"dev": "NODE_ENV=development TZ=UTC nest start --watch",
"start:debug": "NODE_ENV=development TZ=UTC nest start --debug --watch",
"start:prod": "NODE_ENV=production node dist/src/main"
},
"dependencies": {
"@nestjs-modules/mailer": "^1.6.1",
"@nestjs/common": "^9.2.1",
"@nestjs/config": "^2.2.0",
"@nestjs/core": "^10.3.10",
"@nestjs/jwt": "^10.0.1",
"@nestjs/mapped-types": "^1.2.2",
"@nestjs/passport": "^9.0.0",
"@nestjs/platform-express": "^10.3.10",
"@nestjs/schedule": "^2.1.0",
"@nestjs/serve-static": "^4.0.2",
"@nestjs/swagger": "^7.4.0",
"@nestjs/typeorm": "^10.0.2",
"@types/axios": "^0.14.0",
"aws-sdk": "^2.1340.0",
"axios": "^1.7.2",
"bcrypt": "^5.1.0",
"bcryptjs": "^2.4.3",
"cache-manager": "^5.1.7",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.1",
"dotenv": "^16.0.3",
"ejs": "^3.1.8",
"handlebars": "^4.7.7",
"joi": "^17.13.0",
"luxon": "^3.2.1",
"morgan": "^1.10.0",
"multer": "^1.4.5-lts.1",
"node-cache": "^5.1.2",
"nodemailer": "^6.9.14",
"passport": "^0.6.0",
"passport-jwt": "^4.0.1",
"passport-local": "^1.0.0",
"pg": "^8.8.0",
"reflect-metadata": "^0.1.13",
"rimraf": "^4.1.1",
"rxjs": "^7.8.0",
"typeorm": "^0.3.12",
"typeorm-seeding": "^1.6.1"
},
"devDependencies": {
"@faker-js/faker": "^7.6.0",
"@nestjs/cli": "^9.1.8",
"@nestjs/schematics": "^9.0.4",
"@nestjs/testing": "^10.3.10",
"@types/bcrypt": "^5.0.0",
"@types/bcryptjs": "^2.4.6",
"@types/cron": "^2.4.0",
"@types/express": "^4.17.15",
"@types/jest": "^29.2.6",
"@types/lodash": "^4.14.191",
"@types/luxon": "^3.2.0",
"@types/morgan": "^1.9.4",
"@types/multer": "^1.4.7",
"@types/node": "^18.11.18",
"@types/passport-jwt": "^3.0.8",
"@types/passport-local": "^1.0.38",
"@types/supertest": "^2.0.12",
"@typescript-eslint/eslint-plugin": "^5.52.0",
"@typescript-eslint/parser": "^5.52.0",
"eslint": "^8.34.0",
"eslint-config-prettier": "^8.6.0",
"eslint-plugin-prettier": "^4.2.1",
"jest": "^29.3.1",
"prettier": "^2.8.3",
"source-map-support": "^0.5.21",
"supertest": "^6.3.3",
"ts-jest": "^29.0.5",
"ts-loader": "^9.4.2",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.1.2",
"typescript": "^4.9.4"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".*\\.spec\\.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"collectCoverageFrom": [
"**/*.(t|j)s"
],
"coverageDirectory": "../coverage",
"testEnvironment": "node"
},
"overrides": {
"typeorm-seeding": {
"typeorm": "$typeorm"
}
}
}
{
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"target": "es2017",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",
"incremental": true,
"skipLibCheck": true,
"strictNullChecks": false,
"noImplicitAny": false,
"strictBindCallApply": false,
"forceConsistentCasingInFileNames": false,
"noFallthroughCasesInSwitch": false,
"typeRoots": ["./node_modules/@types"]
}
}
When I hit npm run dev from windows machine it shows error
error TS2688: Cannot find type definition file for 'cron'. The file is in the program because: Entry point for implicit type library 'cron'
How can I resolve this ? Thanks in advance
I've just got an issue a couple of days ago,
and my problem is resolved by removing @types/cron
in devDependencies
, remove node_modules, re-build and it's works,