未在通用角度文件上定义文档,更改将无法保存

时间:2018-10-09 09:05:14

标签: angular universal

我已经在这里搜索了答案,但还无法正常工作。

运行“ node dist / server.js”时出现以下错误消息

ReferenceError: document is not defined
at new BrowserPlatform (C:\cmder\Project\dist\server.js:164638:25)
at Object.<anonymous> (C:\cmder\Project\dist\server.js:164682:29)
at __webpack_require__ (C:\cmder\Project\dist\server.js:20:30)
at Object.<anonymous> (C:\cmder\Project\dist\server.js:136679:77)
at __webpack_require__ (C:\cmder\Project\dist\server.js:20:30)
at Object.firebase (C:\cmder\Project\dist\server.js:123364:18)
at __webpack_require__ (C:\cmder\Project\dist\server.js:120467:30)
at Object../src/app/app.component.ts (C:\cmder\Project\dist\server.js:120652:16)
at __webpack_require__ (C:\cmder\Project\dist\server.js:120467:30)
at Object../src/app/app.server.module.ngfactory.js (C:\cmder\Project\dist\server.js:120708:10)

我已经读过,在这种情况下,我应该在文档(和窗口)周围放置if语句。我在dist / server.js文件中所做的:

var BrowserPlatform = /** @class */ (function () {
function BrowserPlatform() {
    this.emptyByteString = '';
    if(document) {this.document = document;}
    if(window) {this.window = window;}
    this.base64Available = typeof atob !== 'undefined';
}

现在,当我运行“ npm run webpack:server”时,这些更改将被删除,所以我在这里的原始文件只有“ this.document = document;”。依此类推,一旦我进入“节点dist / server.js”,错误仍然保持不变

0 个答案:

没有答案