nestjs / nest

A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript 🚀
https://nestjs.com
MIT License
67.69k stars 7.63k forks source link

Nest can't resolve dependencies of the custom Validator with Repository #13228

Closed fanhoucheng closed 8 months ago

fanhoucheng commented 8 months ago

Is there an existing issue for this?

Current behavior

If service with Repository and we have custom validator:

              Error: Nest can't resolve dependencies of the UserValidator (?). Please make sure that the argument dependency at index [0] is available in the UserModule context.

and if remove Repository from service, there is no problem.

user.module.ts: ....

providers: [UserStrategy, UserValidator, UserService, UserRepository],

....

Sample code : https://gitee.com/fanhoucheng/nest-fhc.git

Minimum reproduction code

https://gitee.com/fanhoucheng/nest-fhc.git

Steps to reproduce

Sample code : https://gitee.com/fanhoucheng/nest-fhc.git

Expected behavior

Nest can resolve dependencies of the Validator

Package

Other package

No response

NestJS version

No response

Packages versions

{ "name": "nest-fhc", "version": "0.0.1", "description": "", "author": "", "private": true, "license": "UNLICENSED", "scripts": { "prebuild": "rimraf dist", "build": "nest build", "format": "prettier --write \"src//*.ts\" \"test/*/.ts\"", "start": "cross-env RUNNING_ENV=dev nest start", "dev": "cross-env RUNNING_ENV=dev nest start --watch", "debug": "nest start --debug --watch", "start:prod": "cross-env RUNNING_ENV=prod node dist/main", "lint": "eslint \"{src,apps,libs,test}//.ts\" --fix", "test": "jest", "test:watch": "jest --watch", "test:cov": "jest --coverage", "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", "test:e2e": "jest --config ./test/jest-e2e.json" }, "dependencies": { "@nestjs/common": "^10.0.0", "@nestjs/config": "^3.2.0", "@nestjs/core": "^10.0.0", "@nestjs/jwt": "^10.2.0", "@nestjs/passport": "^10.0.3", "@nestjs/platform-express": "^10.0.0", "@nestjs/platform-socket.io": "^10.3.3", "@nestjs/typeorm": "^10.0.2", "@nestjs/websockets": "^10.3.3", "bcryptjs": "^2.4.3", "better-sqlite3": "^9.4.1", "class-transformer": "^0.5.1", "class-validator": "^0.14.1", "cross-env": "^7.0.3", "dotenv": "^16.4.4", "nest-winston": "^1.9.4", "passport": "^0.7.0", "passport-jwt": "^4.0.1", "passport-local": "^1.0.0", "reflect-metadata": "^0.1.13", "rxjs": "^7.8.1", "typeorm": "^0.3.20", "winston": "^3.11.0", "winston-daily-rotate-file": "^5.0.0" }, "devDependencies": { "@nestjs/cli": "^10.0.0", "@nestjs/schematics": "^10.0.0", "@nestjs/testing": "^10.0.0", "@types/express": "^4.17.17", "@types/jest": "^29.5.2", "@types/node": "^20.3.1", "@types/passport-jwt": "^4.0.1", "@types/passport-local": "^1.0.38", "@types/supertest": "^6.0.0", "@typescript-eslint/eslint-plugin": "^6.0.0", "@typescript-eslint/parser": "^6.0.0", "eslint": "^8.42.0", "eslint-config-prettier": "^9.0.0", "eslint-plugin-prettier": "^5.0.0", "jest": "^29.5.0", "prettier": "^3.0.0", "source-map-support": "^0.5.21", "supertest": "^6.3.3", "ts-jest": "^29.1.0", "ts-loader": "^9.4.3", "ts-node": "^10.9.1", "tsconfig-paths": "^4.2.0", "typescript": "^5.1.3" }, "jest": { "moduleFileExtensions": [ "js", "json", "ts" ], "rootDir": "src", "testRegex": ".\.spec\.ts$", "transform": { "^.+\.(t|j)s$": "ts-jest" }, "collectCoverageFrom": [ "*/.(t|j)s" ], "coverageDirectory": "../coverage", "testEnvironment": "node" } }

Node.js version

No response

In which operating systems have you tested?

Other

No response

Tony133 commented 8 months ago

Hi @fanhoucheng, for this type of question try to use the support discord channel

The NestJS Core team uses GitHub to track bug reports, feature requests, and regressions.

kamilmysliwiec commented 8 months ago

Thank you for taking the time to submit your report! From the looks of it, this could be better discussed on our Discord. If you haven't already, please join here and send a new post in the #⁠ 🐈 nestjs-help forum. Make sure to include a link to this issue, so you don't need to write it all again. We have a large community of helpful members, who will assist you in getting this to work.