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.75k stars 7.63k forks source link

Cannot destructure property `metatype` of 'undefined' or 'null' on related modules #493

Closed twilroad closed 6 years ago

twilroad commented 6 years ago

I'm submitting a...


[ ] Regression 
[√] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

in my project https://github.com/notadd/next, i define a test module like:

import { Module } from "@nestjs/common";

@Module({
})
export class TestModule {

}

thrown a exception:

TypeError: Cannot destructure property `metatype` of 'undefined' or 'null'.
    at flatMap.filter.related (/home/code/next/node_modules/@nestjs/core/injector/injector.js:226:38)
    at Array.filter (<anonymous>)
    at modules.concat.apply.modules.map (/home/code/next/node_modules/@nestjs/core/injector/injector.js:225:62)
    at Array.map (<anonymous>)
    at Injector.flatMap (/home/code/next/node_modules/@nestjs/core/injector/injector.js:223:54)
    at Injector.<anonymous> (/home/code/next/node_modules/@nestjs/core/injector/injector.js:197:46)
    at Generator.next (<anonymous>)
    at /home/code/next/node_modules/@nestjs/core/injector/injector.js:7:71
    at new Promise (<anonymous>)
    at __awaiter (/home/code/next/node_modules/@nestjs/core/injector/injector.js:3:12)
 1: node::Abort() [/usr/bin/node]
 2: 0x11ef459 [/usr/bin/node]
 3: v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) [/usr/bin/node]
 4: 0xb7c08c [/usr/bin/node]
 5: v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/bin/node]
 6: 0x3e8d43f042fd

Expected behavior

Minimal reproduction of the problem with instructions

https://github.com/notadd/next

What is the motivation / use case for changing the behavior?

Environment


Nest version: 4.6.5

For Tooling issues:
- Node version: 9.3
- Platform:  Linux
kamilmysliwiec commented 6 years ago

Please, could you point me to the particular file that throws an exception? It's a little bit difficult to go through the whole codebase. 🙂

twilroad commented 6 years ago

Hello, i add a test module in https://github.com/notadd/next/blob/d7d6b87d1606eb34fcb184541719cd113366c90a/src/injection/modules/test.module.ts, and using it in https://github.com/notadd/next/blob/d7d6b87d1606eb34fcb184541719cd113366c90a/src/injection/modules/addon.module.ts, please clone https://github.com/notadd/next/tree/d7d6b87d1606eb34fcb184541719cd113366c90a for testing, thank you.

kamilmysliwiec commented 6 years ago

Could you let me know whether this bug still appears in the latest version v4.6.6?

twilroad commented 6 years ago

@kamilmysliwiec yes, it still appears in v4.6.6

kamilmysliwiec commented 6 years ago

I did a small investigation and the reason is a circular dependency that exists somewhere (for example, between components). I'd provide more descriptive error messages here. Hence, debugging should be much easier.

yogendradixit-ultra commented 6 years ago

I am getting TypeError: metatype is not a constructor. Please find below error.

Debugger listening on ws://127.0.0.1:9229/7cbd1c87-eb9e-4a22-bd94-b01d7e7a2399 For help see https://nodejs.org/en/docs/inspector [Nest] 30828 - 2018-7-18 14:33:25 [NestFactory] Starting Nest application... [Nest] 30828 - 2018-7-18 14:33:25 [ExceptionHandler] metatype is not a constructor TypeError: metatype is not a constructor at resolveConstructorParams (D:\kltra-test\game-service\node_modules\@nestjs\core\injector\injector.js:64:84) at Injector.resolveConstructorParams (D:\kltra-test\game-service\node_modules\@nestjs\core\injector\injector.js:86:30) at at process._tickDomainCallback (internal/process/next_tick.js:228:7) at Function.Module.runMain (module.js:695:11) at Object. (D:\kltra-test\game-service\node_modules\ts-node\src_bin.ts:177:12) at Module._compile (module.js:652:30) at Object.Module._extensions..js (module.js:663:10) at Module.load (module.js:565:32) at tryModuleLoad (module.js:505:12) 1: node::DecodeWrite 2: v8::internal::wasm::SignatureMap::Find 3: v8::internal::Builtins::CallableFor 4: v8::internal::Builtins::CallableFor 5: v8::internal::Builtins::CallableFor 6: 0000025CCEE843C1 npm ERR! code ELIFECYCLE npm ERR! errno 3 npm ERR! game-service start: ts-node --inspect -r tsconfig-paths/register src/main.ts npm ERR! Exit status 3

weq95 commented 6 years ago

webpack-dev-server --inline --progress --config build/webpack.dev.conf.js

TypeError: Cannot destructure property compile of 'undefined' or 'null'. at addHooks (C:\wamp64\www\vuenews\node_modules\webpack-dev-server\lib\Server.js:114:49) at new Server (C:\wamp64\www\vuenews\node_modules\webpack-dev-server\lib\Server.js:127:5) at startDevServer (C:\wamp64\www\vuenews\node_modules\webpack-dev-server\bin\webpack-dev-server.js:355:14) at processOptions (C:\wamp64\www\vuenews\node_modules\webpack-dev-server\bin\webpack-dev-server.js:309:5) at process._tickCallback (internal/process/next_tick.js:68:7) at Function.Module.runMain (internal/modules/cjs/loader.js:744:11) at startup (internal/bootstrap/node.js:285:19) at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)

zpcjingyu commented 6 years ago

@11084956 我也遇到这个问题了,你解决了吗?

weq95 commented 6 years ago

@zpcjingyu 没有啊

happyring commented 5 years ago

webpack-dev-server --inline --progress --config build/webpack.dev.conf.js

TypeError: Cannot destructure property compile of 'undefined' or 'null'. at addHooks (C:\wamp64\www\vuenews\node_modules\webpack-dev-server\lib\Server.js:114:49) at new Server (C:\wamp64\www\vuenews\node_modules\webpack-dev-server\lib\Server.js:127:5) at startDevServer (C:\wamp64\www\vuenews\node_modules\webpack-dev-server\bin\webpack-dev-server.js:355:14) at processOptions (C:\wamp64\www\vuenews\node_modules\webpack-dev-server\bin\webpack-dev-server.js:309:5) at process._tickCallback (internal/process/next_tick.js:68:7) at Function.Module.runMain (internal/modules/cjs/loader.js:744:11) at startup (internal/bootstrap/node.js:285:19) at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)

    1. How can I solve this problem?

同样的问题,是否解决了?

BobYoung2014 commented 5 years ago

@11084956 我也遇到这个问题了,你解决了吗?

我刚刚也遇到这个问题,执行以下语句解决了: npm install -D webpack-dev-server@3.0.0

希望对你有帮助

BobYoung2014 commented 5 years ago

@zpcjingyu 没有啊

我刚刚也遇到这个问题,执行以下语句解决了: npm install -D webpack-dev-server@3.0.0

希望对你有帮助

weq95 commented 5 years ago

这个版本有点低啊,我看网上都是让升级到4+以上的版本,但是现在我也没管他,只要不进行升级就能跑起来,因为只是用来学习的,也没有深究过,非常感谢告诉解决办法

lock[bot] commented 5 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.