Angular 请添加@Pipe/@Directive/@Component注释3
当以开发方式运行时,此功能正常工作,但当您运行命令以生产时,会出现以下错误: 工作:Angular 请添加@Pipe/@Directive/@Component注释3,angular,typescript,ionic-framework,ionic3,Angular,Typescript,Ionic Framework,Ionic3,当以开发方式运行时,此功能正常工作,但当您运行命令以生产时,会出现以下错误: 工作: ionic cordova run android 不工作: ionic cordova run android --prod --release 错误: [03:34:41] typescript error Unexpected module 'TranslateModule in C:/Users/tm_ma/Doc/PROJECT/node_modules/
ionic cordova run android
不工作:
ionic cordova run android --prod --release
错误:
[03:34:41] typescript error
Unexpected module 'TranslateModule in C:/Users/tm_ma/Doc/PROJECT/node_modules/@ngx-translate/core/core.d.ts' declared by the module 'EmentaPageModule in
C:/Users/tm_ma/Doc/PROJECT/src/pages/ementa/ementa.module.ts'. Please add a
@Pipe/@Directive/@Component annotation.
[03:34:41] ionic-app-script task: "build"
[03:34:41] Error: The Angular AoT build failed. See the issues above
Error: The Angular AoT build failed. See the issues above
import { NgModule, Component } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { EmentaPage } from './ementa'; import { TranslateModule } from '@ngx-translate/core';
@NgModule({
declarations: [
EmentaPage,
TranslateModule
], imports: [
IonicPageModule.forChild(EmentaPage),
TranslateModule
], }) export class EmentaPageModule {}
export function createTranslateLoader(http: HttpClient) {
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}
@NgModule({
declarations: [
...
],
imports: [
BrowserModule,
HttpClientModule,
IonicModule.forRoot(MyApp),
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: (createTranslateLoader),
deps: [HttpClient]
}
})
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
...
],
providers: [
]
})
export class AppModule {}
"@ngx-translate/core": "^9.1.1",
"@ngx-translate/http-loader": "^4.0.0",
"angularfire2": "^5.0.0-rc.11",
"@angular/animations": "5.2.11",
"@angular/common": "5.2.11",
"@angular/compiler": "5.2.11",
"@angular/compiler-cli": "5.2.11",
"@angular/core": "5.2.11",
"@angular/forms": "5.2.11",
"@angular/http": "5.2.11",
校训模块:
[03:34:41] typescript error
Unexpected module 'TranslateModule in C:/Users/tm_ma/Doc/PROJECT/node_modules/@ngx-translate/core/core.d.ts' declared by the module 'EmentaPageModule in
C:/Users/tm_ma/Doc/PROJECT/src/pages/ementa/ementa.module.ts'. Please add a
@Pipe/@Directive/@Component annotation.
[03:34:41] ionic-app-script task: "build"
[03:34:41] Error: The Angular AoT build failed. See the issues above
Error: The Angular AoT build failed. See the issues above
import { NgModule, Component } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { EmentaPage } from './ementa'; import { TranslateModule } from '@ngx-translate/core';
@NgModule({
declarations: [
EmentaPage,
TranslateModule
], imports: [
IonicPageModule.forChild(EmentaPage),
TranslateModule
], }) export class EmentaPageModule {}
export function createTranslateLoader(http: HttpClient) {
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}
@NgModule({
declarations: [
...
],
imports: [
BrowserModule,
HttpClientModule,
IonicModule.forRoot(MyApp),
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: (createTranslateLoader),
deps: [HttpClient]
}
})
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
...
],
providers: [
]
})
export class AppModule {}
"@ngx-translate/core": "^9.1.1",
"@ngx-translate/http-loader": "^4.0.0",
"angularfire2": "^5.0.0-rc.11",
"@angular/animations": "5.2.11",
"@angular/common": "5.2.11",
"@angular/compiler": "5.2.11",
"@angular/compiler-cli": "5.2.11",
"@angular/core": "5.2.11",
"@angular/forms": "5.2.11",
"@angular/http": "5.2.11",
应用程序模块:
[03:34:41] typescript error
Unexpected module 'TranslateModule in C:/Users/tm_ma/Doc/PROJECT/node_modules/@ngx-translate/core/core.d.ts' declared by the module 'EmentaPageModule in
C:/Users/tm_ma/Doc/PROJECT/src/pages/ementa/ementa.module.ts'. Please add a
@Pipe/@Directive/@Component annotation.
[03:34:41] ionic-app-script task: "build"
[03:34:41] Error: The Angular AoT build failed. See the issues above
Error: The Angular AoT build failed. See the issues above
import { NgModule, Component } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { EmentaPage } from './ementa'; import { TranslateModule } from '@ngx-translate/core';
@NgModule({
declarations: [
EmentaPage,
TranslateModule
], imports: [
IonicPageModule.forChild(EmentaPage),
TranslateModule
], }) export class EmentaPageModule {}
export function createTranslateLoader(http: HttpClient) {
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}
@NgModule({
declarations: [
...
],
imports: [
BrowserModule,
HttpClientModule,
IonicModule.forRoot(MyApp),
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: (createTranslateLoader),
deps: [HttpClient]
}
})
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
...
],
providers: [
]
})
export class AppModule {}
"@ngx-translate/core": "^9.1.1",
"@ngx-translate/http-loader": "^4.0.0",
"angularfire2": "^5.0.0-rc.11",
"@angular/animations": "5.2.11",
"@angular/common": "5.2.11",
"@angular/compiler": "5.2.11",
"@angular/compiler-cli": "5.2.11",
"@angular/core": "5.2.11",
"@angular/forms": "5.2.11",
"@angular/http": "5.2.11",
版本:
[03:34:41] typescript error
Unexpected module 'TranslateModule in C:/Users/tm_ma/Doc/PROJECT/node_modules/@ngx-translate/core/core.d.ts' declared by the module 'EmentaPageModule in
C:/Users/tm_ma/Doc/PROJECT/src/pages/ementa/ementa.module.ts'. Please add a
@Pipe/@Directive/@Component annotation.
[03:34:41] ionic-app-script task: "build"
[03:34:41] Error: The Angular AoT build failed. See the issues above
Error: The Angular AoT build failed. See the issues above
import { NgModule, Component } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { EmentaPage } from './ementa'; import { TranslateModule } from '@ngx-translate/core';
@NgModule({
declarations: [
EmentaPage,
TranslateModule
], imports: [
IonicPageModule.forChild(EmentaPage),
TranslateModule
], }) export class EmentaPageModule {}
export function createTranslateLoader(http: HttpClient) {
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}
@NgModule({
declarations: [
...
],
imports: [
BrowserModule,
HttpClientModule,
IonicModule.forRoot(MyApp),
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: (createTranslateLoader),
deps: [HttpClient]
}
})
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
...
],
providers: [
]
})
export class AppModule {}
"@ngx-translate/core": "^9.1.1",
"@ngx-translate/http-loader": "^4.0.0",
"angularfire2": "^5.0.0-rc.11",
"@angular/animations": "5.2.11",
"@angular/common": "5.2.11",
"@angular/compiler": "5.2.11",
"@angular/compiler-cli": "5.2.11",
"@angular/core": "5.2.11",
"@angular/forms": "5.2.11",
"@angular/http": "5.2.11",
角度5应该使用核心8.x-9.x和加载器1.x-2.x 角度4.3应该是使用核心7.x或更小,加载器1.x-2.x 详细情况
我的应用程序使用了ionic4(angular6),ngx translate对我来说还可以(core 10.x和loader 3.x)
TranslateModule
不应该在声明数组中。从中删除后重试there@SurajRao感谢您的回答,我已从declrations数组中删除,知道给我这个->[14:20:09]类型脚本错误无法找到管道“translate”(“{{[error->]'INFOALUNO.headerMsg'|translate}”)