gpt4 book ai didi

jquery - 将应用程序迁移到 Angular 6 : But getting errors while running npm run build --prod. 但命令 npm run build --env=prod 成功运行

转载 作者:太空宇宙 更新时间:2023-11-04 03:01:29 27 4
gpt4 key购买 nike

当我使用命令 npm run build -- --prod 时,我收到以下错误消息:

  • 属性“PropertyName1”是私有(private)属性,只能在“AppComponent”类中访问
  • “AppComponent”类型中不存在属性“PropertyName2”

ERROR in src\app\components\app\app.component.html(77,56): : Property 'validate' is private and only accessible within class 'AppComponent'. src\app\components\entitysearchlight\entitysearchlight.component.html(3,157): : Property 'loadingMessage' is private and only accessible within class 'EntitySearchLightComponent'. src\app\components\entitysearchlight\entitysearchlight.component.html(23,91): : Expected 0 arguments, but got 1. src\app\components\entitysearchlight\entitysearchlight.component.html(97,62): : Property 'e' does not exist on type 'EntitySearchLightComponent'. src\app\components\search\search.component.html(3,157): : Property 'loadingMessage' is private and only accessible within class 'SearchComponent'. src\app\components\search\search.component.html(23,91): : Expected 0 arguments, but got 1. src\app\components\search\search.component.html(57,43): : Property 'onFilterItemSelect' is private and only accessible within class 'SearchComponent'. src\app\components\search\search.component.html(90,58): : Property 'e' does not exist on type 'SearchComponent'.

当我运行时,相同的应用程序成功构建:npm run build --env=prod

您能否告诉我这两个命令如何导致构建过程或配置发生变化?

最佳答案

正如上面所写,您需要将访问修饰符 private 更改为 public。您有一些必要的小文件。但是,您需要避免功能上的问题。

我建议使用 tslint 并检查您的代码。添加tslint.json新规则

"rules": {
...
"member-access": true,

并在各处添加访问修饰符。

package.json中创建命令,您可以在其中检查构建

 "scripts": {
"lint": "ng lint",
...
"building:prod": "npm i && ng lint && ng build --prod"
},

关于jquery - 将应用程序迁移到 Angular 6 : But getting errors while running npm run build --prod. 但命令 npm run build --env=prod 成功运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54983825/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com