2

我正在使用 Azure DevOps YAML 管道来构建/部署我的 Angular 9 应用程序。YAML 包含一个 Powershell 脚本来构建它,如下所示

- powershell: |
    $angularBuildConfiguration = "MyBuildConfig";

    write-host "ng-build start";
    ng build --prod --aot --configuration $angularBuildConfiguration;
    write-host "ng-build end";

  workingDirectory: '$(Build.SourcesDirectory)\...'
  displayName: 'Build app - Angular app'

以上内容通过 Angular 构建,最后返回消息“无法读取未定义的属性 'toLowerCase' 中的错误”。

我已经验证了 workingDirectory 和 angularBuildConfiguration 参数具有预期的值 - 我还用硬编码值替换了它们并获得了相同的结果。如果我在构建服务器(YAML 脚本实际运行的地方)上运行上面的 Powershell 脚本,则在预期的文件夹中构建失败并显示相同的错误消息,但是如果我在本地计算机上使用相同的脚本构建它会成功构建

我不知道这是否是一个 ng 构建问题,或者我的 Angular 9 项目中是否存在导致错误的东西 - 没有标记伴随错误消息的“关联”文件

有没有人有任何想法?

4

2 回答 2

1

This was really random - the toLowerCase message wasn't referring to any javascript/typescript code - it must be an internal message. The only way I could pinpoint where the issue was by process of elimination - i.e. taking out webpages a batch at a time until I got a clean prod compile - then worked back including one by one to get to the culprit.

There was a style that was causing the issue - we replaced the following

.gridlines-left {
  border: 1px solid #c0c0c0;
  border-right-width: 0;
  border-top-width: 0;
  border-bottom-width: 0;
}

...with

.gridlines-left {
  border: 1px solid #c0c0c0;
  border-right-style: none;
  border-top-style: none;
  border-bottom-style: none;
}

...and the compile ran successfully. I still have no idea how/why as we had plenty of other styles very similar and used the same strategy of setting border-right/left/bottom/top-width: 0 - it may have had something to do with how we combined css classes - certain styles may conflict with others come compile time - who knows, but all works well now and haven't had the problem since

于 2020-06-02T03:21:45.020 回答
0

将字符串变量转换为小写时,代码库中存在错误。简单地说,它试图将 undefined 或 false 值转换为小写。

要使用小写的 JavaScript 内置函数,变量应该是真值。

所以在代码库中搜索它,并像下面这样更新它。

If (variable) {
    variable = variable.toString().tolowercase();
}
于 2020-01-21T07:50:10.567 回答