Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upPlease add a @Pipe/@Directive/@Component annotation in Angular 4 #15890
Comments
|
We have the same issue when using ngc. It seems to work fine without it |
|
@rylek90 Hello. Could you please elaborate a little bit what you mean "using ngc". What is ngc? You mean to exclude @angular/compiler-cli? I apologize for perhaps a stupid question, but for me it is unclear. Thank you. |
|
@IevhenIkonnykov what we did is run |
|
@rylek90 Thank you for information. I tried to launch the app by |
|
@IevhenIkonnykov: just to clarify. When using AOT it fails during build. While standard TSC compilation passes it and then fails in runtime with exactly same message as yours. |
|
@rylek90 In my case as you said it fails in runtime, but passes compilation. So you have this problem in both cases with AoT and without it? Did you find anything that might help to fix it? Thank you. |
|
@IevhenIkonnykov: I don't know if it'll help. I've managed to resolve this issue. I've simply forgotten to add resolve dependencies from node_modules in webpack. Hence, in my case this issue was not related to Angular itself. |
|
Thank you. Unfortunately it is not my case, because I use angular cli, but perhaps the problem is there, but it mixed by cli. |
|
I'm having this problem too and have no idea why |
|
Hello, thanks for reporting this. |
|
I will try. I have no idea what caused it, so I'm a bit lost on what to do.
But I'll give it a try.
…On Tue, Apr 11, 2017, 6:17 PM Tobias Bosch ***@***.***> wrote:
Hello, thanks for reporting this.
However, we need a reproduction case for this. For AOT, it would be best
to have a branch on Github with instructions how to reproduce. We
understand that you can't publish your internal app, but it would be great
if you could narrow this down to a simpler app that shows the same problem.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#15890 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAavtPwEddp-cjIEgzcETEDf_5PT-Etvks5rvAn4gaJpZM4M5qH_>
.
|
|
I posted a reproduction, but have learned something new. I am going to try it again with that new information, then post if I still have the problem. |
|
Alright. Here is a full reproduction that demonstrates the problem for me. Here is a sample that reproduces the issue. ng-cli-error To reproduce it manually, perform the following steps;
At the time of this writing, the following packages were updated for me;
ADDITIONAL INFORMATION
|
|
Is this the same issue as #15763? Where 3rd party libraries are causing these errors? |
|
Hello. In my case I do not have side libraries except PrimeNG, but it requires Angular 4. I also have a couple of JavaScript libraries, but they are not the cause. I really cannot find what the cause of this error is and it is even more frustrating, because it works in AoT mode. |
|
My issue was related to the DLLReferencePlugin in Webpack. I had to clean my dll directory and rebuild them. |
|
I'm trying to combine es5 and Typescript like this as i'm trying to build a plugin mechanism. It ends up in the same error. Why is this not possible?
|
|
any update on this? |
|
I saw this error when I added a component to the modules instead of declarations by mistake, check your code. |
|
For now I stay on Angular 2.4.3, because I did not find a way to eradicate this issue. Perhaps I will try to move to Angular 4 later. |
|
@IevhenIkonnykov have you verified this issue on multiple computers? Or is it only when using a special combination of components? My guess is that it only happens in very specific cases, right? Else I guess there would be quite the big fuss around it... |
|
Perhaps it is a specific issue on my computer. I will try to do the same on another one, but I believe that it is something peculiar in one of the components. The most frustrating thing that it works with AoT and majority of Angular errors are not very expressive. |
|
It works perfect with ng serve! BUT, ERROR in ./public/main.ts |
|
Running I couldn't find what's affected by changing EDIT: |
|
@tzachov Your solution |
|
I have the same problem using either of these commands: I can run the normal
|
|
Same here, we trying to use a shared lib which was minified and compiled with gulp typescript (annotations removed) and ts files for references are included. Everytime we try to ng build --prod => Please add a @Pipe/@Directive/@component annotation Everything works fine, with ng build, etc. |
|
I Fixed this error through fix default exports. reference: https://github.com/rangle/angular-2-aot-sandbox#default-exports-top |
|
I'm not sure my solution will correct your issue, but i think you should try to re-order import libs on top of file. |
|
IONIC/ANGULAR: I had the same error, but I solved change my app.module.ts I did the following. import {HttpModule} from '@angular/http'; @NgModule({ ], |
1 similar comment
|
IONIC/ANGULAR: I had the same error, but I solved change my app.module.ts I did the following. import {HttpModule} from '@angular/http'; @NgModule({ ], |
|
I just experienced the error for the first time, did not find an answer here. Found the answer in my case : |
|
I am Facing Same Issues Unexpected value 'ImgMapComponent in /opt/lampp/htdocs/Survey_angular/Survey_new_14_feb/survey/node_modules/ng2-img-map/ng2-img-map.d.ts' declared by the module 'AppModule in /opt/lampp/htdocs/Survey_angular/Survey_new_14_feb/survey/src/app/app.module.ts'. Please add a @Pipe/@Directive/@component annotation. |
|
I had also this problem and in my case it was that i had to add an @ tot the component decorator in my component. It was in some obscure way disappeared. |
|
I saw this error when I added a component to the modules instead of declarations |
|
Don't know if this is still active/open however, for my use-case I had done the following: AppModule.ts
|
|
In my case, I forgot to put "@" before Component. Then this error showed up. |
|
The originally reported issue was solved. This issue starts to accumulate info about unrelated errors and it is no longer serving its purpose so I'm going to close it. If anyone faces this error in the future please open a new issue following our issue template. Thnx! |
|
I had the same as @aditya478492 , I forgot to add the @ to the Component . |
|
I had the same issue, i mistakenly added semi-colon after |
|
Occurred this what can I do? Uncaught Error: Unexpected module 'FormsModule' declared by the module 'AppModule'. Please add a @Pipe/@Directive/@component annotation. |
|
Maybe it's a stupid answer but i have the same issue in a code like this:
Then i just moved '@component' section code near to the exported component and it works.
|
|
i was getting this error when i declared another class in my component just after the component annotation (@component), so module was not able to recognize the component which i declared in declaration. |
|
I faced a similar error. Later realised that it was because I had declared the const outside the component class. Putting them inside the class as public variables resolved the issue. |
Same issue for me, Forgot the @ |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
I'm submitting a ... (check one with "x")
Current behavior
I had a completely working project on Angular 2.4.3 (used Angular cli) and moved it to Angular 4.0.1. I made it twice in a different way. First changed package.json and other necessary files. Second - created an empty project by Angular cli and copied into it my project files. In both cases I get the same error when I try to launch the app with a command
ng serve:compiler.es5.js:14577 Uncaught Error: Unexpected value 'LoadingComponent' declared by the module 'AppModule'. Please add a @Pipe/@Directive/@component annotation.
at syntaxError (http://localhost:4200/vendor.bundle.js:53165:34) []
at http://localhost:4200/vendor.bundle.js:65680:40 []
at Array.forEach (native) []
at CompileMetadataResolver.getNgModuleMetadata (http://localhost:4200/vendor.bundle.js:65662:54) []
at JitCompiler._loadModules (http://localhost:4200/vendor.bundle.js:76740:64) []
at JitCompiler.compileModuleAndComponents (http://localhost:4200/vendor.bundle.js:76699:52) []
at JitCompiler.compileModuleAsync (http://localhost:4200/vendor.bundle.js:76661:21) []
at PlatformRef.bootstrapModuleWithZone (http://localhost:4200/vendor.bundle.js:5145:25) []
at PlatformRef.bootstrapModule (http://localhost:4200/vendor.bundle.js:5131:21) []
at Object.245 (http://localhost:4200/main.bundle.js:16721:124) []
at webpack_require (http://localhost:4200/inline.bundle.js:53:30) []
at Object.776 (http://localhost:4200/main.bundle.js:45425:18) []
at webpack_require (http://localhost:4200/inline.bundle.js:53:30) []
at webpackJsonpCallback (http://localhost:4200/inline.bundle.js:24:23) []
The interesting part is that when I try to launch it with a command
ng serve --aotit works.Expected behavior
Should work as in Angular 2.4.3.
Minimal reproduction of the problem with instructions
Unfortunately it is not an open-source project.
The project is compiled successfully in WebStorm, but it cannot be launched in the browser. My settings are:
LoadingComponent is correct (at least seems to me):
import {Component, Input} from '@angular/core';
@component({
selector: 'cdp-loading',
templateUrl: './loading.component.html'
})
export class LoadingComponent {
@input() public isBusy: boolean;
}
When I remove this component it complains on another and so on.
My package.json:
{
"name": "web-services-ui",
"version": "0.1.0",
"description": "Angular2 SPA",
"license": "ISC",
"author": "Author",
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.config.json",
"build": "ng build",
"lint": "ng lint",
"test": "ng test",
"e2e": "protractor"
},
"private": true,
"dependencies": {
"@angular/common": "^4.0.0",
"@angular/compiler": "^4.0.0",
"@angular/core": "^4.0.0",
"@angular/forms": "^4.0.0",
"@angular/http": "^4.0.0",
"@angular/platform-browser": "^4.0.0",
"@angular/platform-browser-dynamic": "^4.0.0",
"@angular/platform-server": "^4.0.0",
"@angular/router": "^4.0.0",
"@angular/animations": "^4.0.0",
"core-js": "^2.4.1",
"rxjs": "^5.1.0",
"zone.js": "^0.8.4",
"primeng": "^4.0.0-rc.2",
"marked": "0.3.6",
"prismjs": "^1.6.0"
},
"devDependencies": {
"@angular/cli": "1.0.0",
"@angular/compiler-cli": "^4.0.0",
"@types/jasmine": "2.5.38",
"@types/node": "~6.0.60",
"codelyzer": "~2.0.0",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"karma": "~1.4.1",
"karma-chrome-launcher": "~2.0.0",
"karma-cli": "~1.0.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-coverage-istanbul-reporter": "^0.2.0",
"protractor": "~5.1.0",
"ts-node": "~2.0.0",
"tslint": "~4.5.0",
"typescript": "~2.2.0"
}
}
My AppModule:
@NgModule({
declarations: [
AppComponent,
OpenDirective,
HeaderComponent,
NavigationSiteDirectoryComponent,
NavigationComponent,
FooterComponent,
ContentComponent,
HomeComponent,
LoadingComponent,
OpenEngineeringModelModalComponent,
LogoutComponent,
ModalContainerComponent,
ModelNavigationContainerComponent,
NavigationModelComponent,
ControlSideBarComponent
],
imports: [
BrowserModule,
HttpModule,
APP_ROUTER_PROVIDERS,
FormsModule,
ReactiveFormsModule,
CommonModule,
CDP4SharedModule,
RequirementModule,
SiteDirectoryModule,
EngineeringModelModule,
RIDModule,
EngineeringModelDataNoteModule,
FileStoreModule
],
providers: [
{provide: APP_BASE_HREF, useValue: '/'},
BusyIndicatorService,
ThingUpdateService,
WebServiceClient,
CdpServicesDal,
ModelNavigationService,
UserSessionService,
SiteDirectoryResolver,
EngineeringModelResolver,
DialogService,
ValidationService,
TreeTableService,
RequirementTreeTableService,
SharedTreeTableService,
FileStoreTreeTableService,
PersonTreeTableService,
ConfigService,
{provide: APP_INITIALIZER, useFactory: initConfig, deps: [ConfigService], multi: true }
],
bootstrap: [AppComponent]
})
export class AppModule {
}
What is the motivation / use case for changing the behavior?
If this configuration worked in Angular 2.4.3 it should work in Angular 4.0.1.
Please tell us about your environment:
Windows 7 64bit, Webstorm 2016.3.3, npm 4.1.1
Language: Typescript 2.2.2
Node (for AoT issues):
node --version= 7.4.0