Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nestjs undefined injected class method #37

Closed
Satont opened this issue Jun 19, 2022 · 2 comments
Closed

Nestjs undefined injected class method #37

Satont opened this issue Jun 19, 2022 · 2 comments
Labels

Comments

@Satont
Copy link

Satont commented Jun 19, 2022

I got error on appService property:

TypeError: Cannot read properties of undefined (reading 'getHello')
    at AppController.getHello (/home/satont/Tests/project-name/src/app.controller.ts:10:28)
    at <anonymous> (/home/satont/Tests/project-name/node_modules/.pnpm/@[email protected]_fkqgj3xrohk2pflugljc4sz7ea/node_modules/@nestjs/core/router/router-execution-context.js:38:29)
    at InterceptorsConsumer.intercept (/home/satont/Tests/project-name/node_modules/.pnpm/@[email protected]_fkqgj3xrohk2pflugljc4sz7ea/node_modules/@nestjs/core/interceptors/interceptors-consumer.js:11:20)
    at <anonymous> (/home/satont/Tests/project-name/node_modules/.pnpm/@[email protected]_fkqgj3xrohk2pflugljc4sz7ea/node_modules/@nestjs/core/router/router-execution-context.js:46:60)
    at <anonymous> (/home/satont/Tests/project-name/node_modules/.pnpm/@[email protected]_fkqgj3xrohk2pflugljc4sz7ea/node_modules/@nestjs/core/router/router-proxy.js:9:23)
    at Layer.Layer.handle_request (/home/satont/Tests/project-name/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/layer.js:95:5)
    at next (/home/satont/Tests/project-name/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/route.js:144:13)
    at Route.Route.dispatch (/home/satont/Tests/project-name/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/route.js:114:3)
    at Layer.Layer.handle_request (/home/satont/Tests/project-name/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/layer.js:95:5)
    at <anonymous> (/home/satont/Tests/project-name/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/index.js:284:15)

When class imported via nestjs DI as constructor(private readonly appService: AppService) {}

Reproduction:

npm i -g @nestjs/cli
nest new project-name
cd project-name
pnpm install
tsx src/main.ts
curl http://localhost:3000

Or you can clone https://github.com/nestjs/typescript-starter, and perform latest 3 steps.

tsx version: 3.4.3
nodejs version: 18.2.0

Also as fact, i tested CJS and ESM, same behavior.

@privatenumber
Copy link
Owner

esbuild doesn't support decorators (emitDecoratorMetadata in tsconfig.json): evanw/esbuild#257

Closing as a duplicate of #347

@Satont
Copy link
Author

Satont commented Jun 19, 2022

esbuild doesn't support decorators (emitDecoratorMetadata in tsconfig.json): evanw/esbuild#257

Closing as a duplicate of esbuild-kit/tsx#347

Ah, sorry, somehow i missed that issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants