gpt4 book ai didi

nestjs - 在生产模式下启动 nestjs

转载 作者:行者123 更新时间:2023-12-04 02:43:47 27 4
gpt4 key购买 nike

我正在使用我购买的 akveo 后端包,虽然在开发模式下一切似乎都在生产中运行良好,但出现了以下错误,但我对 nestjs 本身并不熟悉。
有谁知道这里发生了什么?

node_modules/@nestjs/core/adapters/http-adapter.d.ts:5:31 - error TS2420: Class 'AbstractHttpAdapter<TServer, TRequest, TResponse>' incorrectly implements interface 'HttpServer<TRequest, TResponse>'.
Property 'status' is missing in type 'AbstractHttpAdapter<TServer, TRequest, TResponse>' but required in type 'HttpServer<TRequest, TResponse>'.

5 export declare abstract class AbstractHttpAdapter<TServer = any, TRequest = any, TResponse = any> implements HttpServer<TRequest, TResponse> {
~~~~~~~~~~~~~~~~~~~

node_modules/@nestjs/common/interfaces/http/http-server.interface.d.ts:26:5
26 status(response: any, statusCode: number): any;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'status' is declared here.

node_modules/@nestjs/core/application-config.d.ts:2:39 - error TS2307: Cannot find module '@nestjs/common/interfaces/configuration-provider.interface'.

2 import { ConfigurationProvider } from '@nestjs/common/interfaces/configuration-provider.interface';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@nestjs/core/guards/guards-context-creator.d.ts:3:39 - error TS2307: Cannot find module '@nestjs/common/interfaces/configuration-provider.interface'.

3 import { ConfigurationProvider } from '@nestjs/common/interfaces/configuration-provider.interface';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@nestjs/core/interceptors/interceptors-context-creator.d.ts:2:39 - error TS2307: Cannot find module '@nestjs/common/interfaces/configuration-provider.interface'.

2 import { ConfigurationProvider } from '@nestjs/common/interfaces/configuration-provider.interface';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@nestjs/core/nest-application.d.ts:24:5 - error TS2416: Property 'getHttpAdapter' in type 'NestApplication' is not assignable to the same property in base type 'INestApplication'.
Type '() => AbstractHttpAdapter<any, any, any>' is not assignable to type '() => HttpServer<any, any>'.
Property 'status' is missing in type 'AbstractHttpAdapter<any, any, any>' but required in type 'HttpServer<any, any>'.

24 getHttpAdapter(): AbstractHttpAdapter;
~~~~~~~~~~~~~~

node_modules/@nestjs/common/interfaces/http/http-server.interface.d.ts:26:5
26 status(response: any, statusCode: number): any;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'status' is declared here.


Found 5 errors.

我正在使用 tsc -p tsconfig.build.json使用 tsconfig.build.json 构建它的命令:
{
"extends": "./tsconfig.json",
"exclude": ["node_modules", "test", "**/*spec.ts"]
}

tsconfig.json :
{
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es6",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./"
},
"exclude": ["node_modules"]
}

我希望这个配置应该将 typescript 代码编译成 javascript,然后我会用 node dist/main.js 运行命令。它实际上是这样做的。但我担心 typescript 编译器错误。

最佳答案

不确定没有代码,但曾在 nest 核心包中遇到过类似的不匹配。退房 package.json并确保所有 @nest软件包具有相同的版本,因为有时即使不是主要版本,它们也会有“破坏性”更改。

对于一个抽象的例子,类似的东西给了我与 core 相关的错误。在构建生产时:

   "@nestjs/common": "6.6.0",  // notice the core/common does not match, it should be bumped
"@nestjs/core": "6.6.2",

关于nestjs - 在生产模式下启动 nestjs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58084087/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com