TypeError: provideModuleMap is not a function ~ NestJS

TypeError: provideModuleMap is not a function ~ NestJS

升级 NestJS 后出现以下错误 TypeError: provideModuleMap is not a function。在 Angular 中使用 NestJS 进行服务器端渲染 (SSR),结合 Angular 通用渲染 SSR。

正确工作依赖项:

"@nestjs/common": "^6.3.1",
"@nestjs/core": "^6.3.1",
"@nestjs/ng-universal": "^1.2.0",
"@nestjs/platform-express": "^6.3.1"

更新的依赖项导致错误:

"@nestjs/common": "^6.5.2",
"@nestjs/core": "^6.5.2",
"@nestjs/ng-universal": "^2.0.0",
"@nestjs/platform-express": "^6.5.2"

nguniversal 依赖项(它们不会更改):

"@nguniversal/common": "^8.1.1",
"@nguniversal/express-engine": "^8.1.1",
"@nguniversal/module-map-ngfactory-loader": "^8.1.1",
"express": "^4.17.1",

使用 Angular 8.2.0。其他文件(app.server.module.ts 等)应该没问题,因为使用 SSR 时 SSR 工作得很好。完整错误日志:

TypeError: provideModuleMap is not a function
    at View.app.engine (C:\users\myapp\node_modules\@nestjs\ng-universal\dist\utils\setup-universal.utils.js:23:17)
    at View.render (C:\users\myapp\node_modules\express\lib\view.js:135:8)
    at tryRender (C:\users\myapp\node_modules\express\lib\application.js:640:10)
    at Function.render (C:\users\myapp\node_modules\express\lib\application.js:592:3)
    at ServerResponse.render (C:\users\myapp\node_modules\express\lib\response.js:1012:7)
    at app.get (C:\users\myapp\node_modules\@nestjs\ng-universal\dist\angular-universal.module.js:60:66)
    at Layer.handle [as handle_request] (C:\users\myapp\node_modules\express\lib\router\layer.js:95:5)
    at next (C:\users\myapp\node_modules\express\lib\router\route.js:137:13)
    at Route.dispatch (C:\users\myapp\node_modules\express\lib\router\route.js:112:3)
    at Layer.handle [as handle_request] (C:\users\myapp\node_modules\express\lib\router\layer.js:95:5)

我无法在 Nest 存储库中找到任何文档,但查看了 AngularUniversalModule 的选项界面,我尝试了这个并使其正常工作:

import { Module } from '@nestjs/common';
import { AngularUniversalModule, applyDomino } from '@nestjs/ng-universal';
import { join, resolve } from 'path';
import { ngExpressEngine } from '@nguniversal/express-engine';
import { provideModuleMap } from '@nguniversal/module-map-ngfactory-loader';

const config = require('config');

// Path to server bundle in dist
const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require('../../../../dist/server/main');

applyDomino(global, join(resolve(), `${config.Http.distDir}/client/index.html`));

@Module({
    imports: [
        AngularUniversalModule.forRoot({
            // Path to client code in dist
            viewsPath: join(resolve(), `${config.Http.distDir}/client`),
            bundle: {
                AppServerModuleNgFactory,
                LAZY_MODULE_MAP,
                provideModuleMap,
                ngExpressEngine
            }
        })
    ],
})
export class CoreModule
{
}

server.ts

const { provideModuleMap } = require('@nguniversal/module-map-ngfactory-loader');