Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 8 typescript文件替换错误_Angular_Typescript_Npm_Angular8_Ng Build - Fatal编程技术网

Angular 8 typescript文件替换错误

Angular 8 typescript文件替换错误,angular,typescript,npm,angular8,ng-build,Angular,Typescript,Npm,Angular8,Ng Build,我正在用angular.js配置替换html文件,但如果我需要替换组件中的typescript文件,它会显示错误。我用的是角度8 angular.js "production": { "fileReplacements": [ { "replace": "src/environments/environment.ts", // GOOD "with": &quo

我正在用angular.js配置替换html文件,但如果我需要替换组件中的typescript文件,它会显示错误。我用的是角度8

angular.js

"production": {
  "fileReplacements": [
    {
      "replace": "src/environments/environment.ts", // GOOD
      "with": "src/environments/environment.prod.ts"
    },
    {
      "replace": "src/theme.css", // GOOD
      "with": "src/theme.prod.css"
    },
    {
      "replace": "src/app/login/login.component.html", // GOOD
      "with": "src/app/login/login.component.prod.html"
    },
    {
      "replace": "src/app/login/login.component.ts", // ERROR
      "with": "src/app/login/login.component.prod.ts"
    }
  ],
错误

ERROR in : Cannot determine the module for class LoginComponent in /src/app/login/login.component.prod.ts! Add LoginComponent to the NgModule to fix it.
我在“prod”和“normal”文件中有这个组件头


是否有方法替换组件中的typescript文件?

也许您需要将
login.module.ts
添加到文件替换中,并提供产品登录组件的正确声明。如果这不起作用,也许您可以检查登录组件中的环境,并直接在其中更改行为。在声明下的模块中,您必须具有
LoginComponent
。该文件可能无法导入组件。可能与我在
app.module.ts
中有该声明有关,添加“替换文件”选项时会出现错误。
@Component({
  selector: 'app-login',
  templateUrl: './login.component.html',
  styleUrls: ['./login.component.css']
})