nest: Upgrade To 5.0.0 Breaks Server Bootup - Nest can't resolve dependencies
This potential bug crashes the Nestjs server on bootup and stops all development work on the front and back ends.
I’m submitting a…
[ ] Regression
[x ] 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
Booting Nestjs with npm run start gives this message and the server won’t boot:
[Nest] 24918 - 2018-5-22 18:44:51 [NestFactory] Starting Nest application...
[Nest] 24918 - 2018-5-22 18:44:52 [InstanceLoader] TypeOrmModule dependencies initialized +277ms
[Nest] 24918 - 2018-5-22 18:44:52 [ExceptionHandler] Nest can't resolve dependencies of the MembersService (?). Please verify whether [0] argument is available in the current context.
Error: Nest can't resolve dependencies of the MembersService (?). Please verify whether [0] argument is available in the current context.
at Injector.lookupComponentInExports (/home/vagrant/nestjs/node_modules/@nestjs/core/injector/injector.js:129:19)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
at Function.Module.runMain (module.js:695:11)
at startup (bootstrap_node.js:191:16)
at bootstrap_node.js:612:3
1: node::Abort() [node]
2: 0x8c2459 [node]
3: v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) [node]
4: 0xad6f2c [node]
5: v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) [node]
6: 0x25713df842fd
Aborted (core dumped)
npm ERR! code ELIFECYCLE
npm ERR! errno 134
npm ERR! Project_Fuser_Nestjs@1.0.0 start: `node index.js`
npm ERR! Exit status 134
npm ERR!
npm ERR! Failed at the Project_Fuser_Nestjs@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Expected behavior
After the minor modification to a service of replacing @Component with @Injectable the server should just boot up. The code worked with full CRUD before the upgrade to v5.
Minimal reproduction of the problem with instructions
The error message seems to relate to the following code.
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { Members } from './members.entity';
@Injectable()
export class MembersService {
constructor(
@InjectRepository(Members)
private readonly membersRepository: Repository<Members>,
) {}
async findAll(): Promise<Members[]> {
return await this.membersRepository.find();
}
...
}
What is the motivation / use case for changing the behavior?
Nestjs server boots and full CRUD returns.
Environment
Nest version: 5.0.0 / @nestjs/typeorm 3.0.0 / TypeORM 0.2.6
/ Express 4.16.3 / RxJS 6.1.0 / @nestjs/cli 5.1.2
For Tooling issues:
- Node version: 8.11.2
- Platform: Ubuntu server 16.04.4
Others:
IDE Webstorm 2018.1.3 (the latest).
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 16 (3 by maintainers)
I’ve solved the problem! It didn’t work because I tried to import a service from another module instead of this module… 😃
Thanks @ThomRick but TypeORM is in my package.json and installed “├── typeorm@0.2.6”
Thanks for reporting this Vadim. I had to roll back to 4.6 and it is working very well. I’ll wait for this issue to be fixed before trying to upgrade again.