我正在使用我购买的 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.
Run Code Online (Sandbox Code Playgroud)
我正在使用tsc -p tsconfig.build.json命令来构建它tsconfig.build.json:
{
"extends": "./tsconfig.json",
"exclude": ["node_modules", "test", "**/*spec.ts"]
}
Run Code Online (Sandbox Code Playgroud)
和tsconfig.json:
{
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es6",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./"
},
"exclude": ["node_modules"]
}
Run Code Online (Sandbox Code Playgroud)
我希望这个配置应该将打字稿代码编译为 javascript,然后我将使用node dist/main.js命令运行。它实际上是这样做的。但我担心打字稿编译器错误。
不确定没有代码,但曾在 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",
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1826 次 |
| 最近记录: |