【问题标题】:angular server side build error not able to find error角度服务器端构建错误无法找到错误
【发布时间】:2020-05-22 04:10:13
【问题描述】:

我正在使用带有服务器端构建的 Angular 8 项目,但在服务器端出现错误。问题在这里我无法找到错误来自哪个文件它显示错误来自非常大的构建文件所以我无法确定错误来自哪里。请让我知道如何使服务器端构建,以便从源代码而不是构建中显示错误。

错误:

ERROR { TypeError: Cannot read property 'length' of null
        at Object.updateDirectives (httpdocs/dist/server/main.js:95468:326)
        at Object.debugUpdateDirectives [as updateDirectives] (httpdocs/dist/server/main.js:77487:21)
        at checkAndUpdateView (httpdocs/dist/server/main.js:76499:14)
        at callViewAction (httpdocs/dist/server/main.js:76865:21)
        at execComponentViewsAction (httpdocs/dist/server/main.js:76793:13)
        at checkAndUpdateView (httpdocs/dist/server/main.js:76506:5)
        at callViewAction (httpdocs/dist/server/main.js:76865:21)
        at execEmbeddedViewsAction (httpdocs/dist/server/main.js:76822:17)
        at checkAndUpdateView (httpdocs/dist/server/main.js:76500:5)
        at callViewAction (httpdocs/dist/server/main.js:76865:21)

【问题讨论】:

  • 您是否尝试过在没有服务器端的情况下进行构建?您应该在浏览器控制台中收到一条错误消息。
  • @Duki 我只在服务器端没有浏览器端收到错误。有什么方法可以在不捆绑服务器端代码的情况下运行应用程序。

标签: node.js angular webpack build server-side-rendering


【解决方案1】:

检查您正在使用其属性的对象是否不为空或未定义是一个很好的做法。因此,如果可以,请尝试以下方法:

假设您有一个名为variable 的对象(可能是字符串、对象、数组...)。无论您在哪里使用过variable.length,请在其前面添加variable &&

例如,如果你有

if(variabe.length > 0){
   //Do something
}

使用

if(variable && variabe.length > 0){
   //Do something
}

也许对你有帮助。

【讨论】:

  • 实际上我无法找到错误来自的文件。有什么方法可以在不捆绑服务器端代码的情况下运行应用程序。
猜你喜欢
  • 2022-11-22
  • 2023-01-26
  • 2019-01-14
  • 1970-01-01
  • 2015-10-10
  • 2017-12-01
  • 2018-03-09
  • 1970-01-01
  • 2018-04-06
相关资源
最近更新 更多