我使用的是我购买的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"]
}
我希望此配置应将打字稿代码编译为javascript,然后使用node dist/main.js
命令运行。它实际上是做什么的。但是我担心打字稿编译器错误。
答案 0 :(得分:1)
不确定是否没有代码,但是曾经在嵌套核心程序包中有类似的不匹配。检出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",