升级到7后,Nestjs无法启动。
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了升级到7后,Nestjs无法启动。相关的知识,希望对你有一定的参考价值。
我今天将我的Nest应用程序从6 -> 7升级。在解决了所有的排版错误后,我在启动时得到了奇怪的行为。
[Nest] 15484 - 05/01/2020, 3:33:29 PM [NestFactory] Starting Nest application...
[Nest] 15484 - 05/01/2020, 3:33:29 PM [InstanceLoader] GraphqlClientModule dependencies initialized +138ms
[Nest] 15484 - 05/01/2020, 3:33:29 PM [InstanceLoader] SentryModule dependencies initialized +1ms
[Nest] 15484 - 05/01/2020, 3:33:29 PM [InstanceLoader] TypeOrmModule dependencies initialized +0ms
[Nest] 15484 - 05/01/2020, 3:33:29 PM [InstanceLoader] HttpModule dependencies initialized +2ms
[Nest] 15484 - 05/01/2020, 3:33:29 PM [InstanceLoader] JwtModule dependencies initialized +0ms
[Nest] 15484 - 05/01/2020, 3:33:29 PM [InstanceLoader] ConfigHostModule dependencies initialized +0ms
[Nest] 15484 - 05/01/2020, 3:33:29 PM [InstanceLoader] DiscoveryModule dependencies initialized +0ms
[Nest] 15484 - 05/01/2020, 3:33:29 PM [InstanceLoader] ConsoleModule dependencies initialized +2ms
[Nest] 15484 - 05/01/2020, 3:33:29 PM [InstanceLoader] ConfigModule dependencies initialized +1ms
[Nest] 15484 - 05/01/2020, 3:33:29 PM [InstanceLoader] ConfigModule dependencies initialized +0ms
[Nest] 15484 - 05/01/2020, 3:33:29 PM [InstanceLoader] BullModule dependencies initialized +12ms
[Nest] 15484 - 05/01/2020, 3:33:29 PM [InstanceLoader] ScheduleModule dependencies initialized +0ms
[Nest] 15484 - 05/01/2020, 3:33:29 PM [InstanceLoader] StorageModule dependencies initialized +7ms
[Nest] 15484 - 05/01/2020, 3:33:29 PM [InstanceLoader] KeyValueModule dependencies initialized +1ms
[Nest] 15484 - 05/01/2020, 3:33:29 PM [InstanceLoader] IntercomModule dependencies initialized +0ms
[Nest] 15484 - 05/01/2020, 3:33:29 PM [InstanceLoader] SentryCoreModule dependencies initialized +88ms
[Nest] 15484 - 05/01/2020, 3:33:29 PM [InstanceLoader] BullModule dependencies initialized +0ms
[Nest] 15484 - 05/01/2020, 3:33:29 PM [InstanceLoader] JwtModule dependencies initialized +0ms
[Nest] 15484 - 05/01/2020, 3:33:29 PM [InstanceLoader] GraphQLSchemaBuilderModule dependencies initialized +1ms
[Nest] 15484 - 05/01/2020, 3:33:29 PM [InstanceLoader] PostmarkModule dependencies initialized +0ms
[Nest] 15484 - 05/01/2020, 3:33:29 PM [InstanceLoader] GraphQLModule dependencies initialized +1ms
然后它就停止了。没有额外的输出。还有很多模块。
以下是相关的包
"@nestjs/cli": "^7.1.4",
"@nestjs/common": "^7.0.9",
"@nestjs/config": "^0.4.0",
"@nestjs/core": "^7.0.9",
"@nestjs/graphql": "^7.3.5",
"@nestjs/jwt": "^7.0.0",
"@nestjs/platform-express": "^7.0.9",
"@nestjs/schedule": "^0.3.1",
"@nestjs/schematics": "^7.0.0",
"@nestjs/typeorm": "^7.0.0",
供参考,以下是我的 main.ts
import { NestFactory } from "@nestjs/core";
import { AppModule } from "./app.module";
import {
initializeTransactionalContext,
patchTypeORMRepositoryWithBaseRepository
} from "typeorm-transactional-cls-hooked";
import { ValidationPipe } from "@nestjs/common";
import helmet from "helmet";
initializeTransactionalContext();
patchTypeORMRepositoryWithBaseRepository();
async function bootstrap() {
const app = await NestFactory.create(AppModule, { bodyParser: false });
app.enableCors();
app.use(helmet());
app.useGlobalPipes(new ValidationPipe());
await app.listen(process.env.PORT || 3000);
}
bootstrap();
更新一下。
在我的应用模块里,我试着把所有的应用模块都注释掉 但应用却无法启动。我试着注释掉所有的应用模块,但应用不能启动。都 模块,然后应用程序启动
当我加入 只是 TypeOrmModule.forRoot()
,应用程序挂起,不启动。
答案
我有一个有点不满意的答案。我升级Nest包的时候,忘了说nest的一个依赖关系说我的Node版本不够高。我用的是13.x,但它要的是13.6以上的版本,我相信。
我想,"我就用最新的吧",于是我去了14.x。
当我转到node 13.14.0时,这个问题就解决了。
以上是关于升级到7后,Nestjs无法启动。的主要内容,如果未能解决你的问题,请参考以下文章
NestJS:无法读取未定义的属性“'createObjectLiteralExpression'”
用homebrew将php 7.1升级到7.2后,无法在Mac上重启Apache
nodejs升级后运行apollo服务器的问题(使用nestjs和fastify)