NestJS Monorepo中「Class extends value undefined」错误求助
NestJS Monorepo中
Class extends value undefined is not a constructor or null错误排查求助 在NestJS Monorepo环境下遇到编译期错误Class extends value undefined is not a constructor or null。最初误以为仅执行npx nest start <application name>时会触发该错误,后续发现执行npx nest start同样会出现问题。
已排查类层级结构,确认不存在循环依赖。将抽象基类AssetBase修改为接口后错误消失,但不清楚背后的原因,特此求助。
错误栈信息
export class Boiler extends AssetBase { ^ TypeError: Class extends value undefined is not a constructor or null at Object.<anonymous> (C:\Users\...\apps\world1\src\assets\boiler.ts:13:29) at Module._compile (node:internal/modules/cjs/loader:1218:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1272:10) at Module.load (node:internal/modules/cjs/loader:1081:32) at Function.Module._load (node:internal/modules/cjs/loader:922:12) at Module.require (node:internal/modules/cjs/loader:1105:19) at require (node:internal/modules/cjs/helpers:103:18) at Object.<anonymous> (C:\Users\...\apps\world1\src\assets\asset-base.ts:5:1) at Module._compile (node:internal/modules/cjs/loader:1218:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
项目nest-cli.json配置
{ "monorepo": true, "root": "apps/world1", "sourceRoot": "apps/world1/src", "compilerOptions": { "webpack": false, "tsConfigPath": "apps/world1/tsconfig.app.json" }, "projects": { "controller1": { "type": "application", "root": "apps/controller1", "entryFile": "main", "sourceRoot": "apps/controller1/src", "compilerOptions": { "tsConfigPath": "apps/controller1/tsconfig.app.json" } }, "dtos": { "type": "library", "root": "libs/dtos", "entryFile": "index", "sourceRoot": "libs/dtos/src", "compilerOptions": { "tsConfigPath": "libs/dtos/tsconfig.lib.json" } }, "world1": { "type": "application", "root": "apps/world1", "entryFile": "main", "sourceRoot": "apps/world1/src", "compilerOptions": { "tsConfigPath": "apps/world1/tsconfig.app.json" } }, "general": { "type": "library", "root": "libs/general", "entryFile": "index", "sourceRoot": "libs/general/src", "compilerOptions": { "tsConfigPath": "libs/general/tsconfig.lib.json" } }, "algorithm1": { "type": "application", "root": "apps/algorithm1", "entryFile": "main", "sourceRoot": "apps/algorithm1/src", "compilerOptions": { "tsConfigPath": "apps/algorithm1/tsconfig.app.json" } } } }
修改前的抽象类AssetBase
export abstract class AssetBase { constructor(readonly config: AssetConfigBaseDto) {} abstract simulationStep( period: Period, beginState?: AssetStateBaseDto, controls?: AssetControlsBaseDto, ): AssetStepResponse }
修改后的接口AssetBase
export interface AssetBase { readonly config: AssetConfigBaseDto simulationStep( period: Period, beginState?: AssetStateBaseDto, controls?: AssetControlsBaseDto, ): AssetStepResponse }
内容的提问来源于stack exchange,提问作者Stefaan Vandevelde
相关产品推荐
相关产品推荐

