TypeError:无法读取未定义的属性'CreateObjectURL'

我们有一个角度应用程序,我正在尝试将服务器端渲染(SSR)应用于我们现有的Angular SEO和链接预览应用程序:

Angular Version: 8.2.3

我执行的将其转换为SSR的步骤:

  1. 使用Angular CLI添加Angular Universal

ng add @nguniversal/express-engine --clientProject {{ name of your project }}

  1. 我正在使用的构建命令

npm run build:ssr && npm run serve:ssr

    我使用domino在server.ts中添加的
  1. 窗口对象和其他polyfills
import fs from 'fs';
const template = fs.readFileSync(join(DIST_FOLDER,'index.html')).toString();
import { Blob } from "blob-polyfill";

const win = domino.createWindow(template);
global['window'] = win;
global['document'] = win.document;
global["branch"] = null;
global["object"] = win.object;
global["HTMLElement"] = win.HTMLElement;
global["navigator"] = win.navigator;
global['Blob'] = Blob;

/** NOTE :: leave this as require() since this file is built Dynamically from webpack */
const {AppServerModuleNgFactory,LAZY_MODULE_MAP,ngExpressEngine,provideModuleMap} = require('./dist/server/main');

/** Our Universal express-engine (found @ https://github.com/angular/universal/tree/master/modules/express-engine) */
app.engine('html',ngExpressEngine({
  bootstrap: AppServerModuleNgFactory,providers: [
    provideModuleMap(LAZY_MODULE_MAP)
  ]
}));

我试图检查它是否是任何第三方软件包,如果它引起错误,我可以理解它是aws-aplify-angular,其中有aws-lex-audio.js,其中包含该行导致该错误。甚至我都没有使用包含该文件的interactions module。但是仍然没有运气。

我尝试过的解决方案,

如果有帮助,我尝试使用放大模块化方法排除交互模块

    {
        provide: AmplifyService,useFactory:  () => {
          return AmplifyModules({
            Auth,Storage,});
        }
    },]

有什么办法可以消除此错误?

TypeError:无法读取未定义的属性'CreateObjectURL'

gaoyueze 回答:TypeError:无法读取未定义的属性'CreateObjectURL'

这里的问题是您正在使用aws-amplify-angular并将其导入到模块中的某个位置。

这也将导入交互模块,即使您不需要使用它。只要确保不使用此模块,您就可以了。

本文链接:https://www.f2er.com/3009981.html

大家都在问