-
Notifications
You must be signed in to change notification settings - Fork 12k
JIT mode only: Uncaught Error: Unexpected value imported by the module 'AppModule'. Please add a annotation. #7409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I installed cli 1.2.7 as @ebtc mentioned but I'm still getting the same error. Output from ng serve
|
Same issue with JIT (build works but fails at runtime). AOT works fine. Used to work with:
But once upgraded to the following versions, it started to fail:
update: Its working with angular-cli 1.2.7 |
Same error here when symlinking / npm-linking an external module from ng-cli 1.3.x. Fixing |
A simple reproduction of this issue is available at bgotink/angular-cli-symlink-reproduction As already mentioned above:
@anjmao I think you're missing the {
// ...
"compilerOptions": {
// ...
"baseUrl": "",
"paths": {
"@angular/*": ["../node_modules/@angular/*"]
}
}
} it works with |
Thanks @bgotink, after adding paths it started to work in JIT mode on @angular/[email protected] |
@hansl did an update to the way paths get read: d1d2aa0. Has anyone gotten his modules to work with this? Any other solutions? |
After digging through issues, I just figured this one : #7137 |
Just wondering if there was a fix for this issue coming up, or if there was a decision in the correct pattern to follow when developing angular libraries? I'm currently on cli 1.4.2, and I'm having the same issue when using
I would really appreciate any feedback/guidance. Thanks for all the hard work in building a killer CLI! |
@dbfannin I've been struggling with this as well, my comments in this issue report might help. In short, avoid having |
@matthewhegarty, thanks for link! I've been using (basically) that same method for the past month or so, thinking it would just be a stopgap solution until this "bug" was fixed. Unfortunately, I've found it to be really inconvenient to develop this way, especially in an architecture that relies heavily on shared modules. For anyone else feeling this pain, I've just been enabling AOT when serving up my application ( |
I came across this whilst looking into this issue. I think this is related but a different issue. If it helps, I've included some steps to reproduce. The issue occurs if you create a local path to a package, but have a separate dependency In the example below, the 'angular-datatables' library bundles Attachments
Steps to reproduce
Workaround
|
A lot of these solutions are hacks which seem unpractical, especially when it comes to maintainability. A core/shared library is that way because it holds system critical functionality. I much rather not get used to deleting angular/core folders out of a (or many) library(ies). I have been trying to follow yeoman's library seed to properly build a lib (which looks somewhat similar to what @filipesilva is building) as the way to go (to take out my inexperience). But I still run into these issues as described above. It is quite frustrating. Obviously there are many more out there that have abstracted core code into a lib. A good solution, or a fix, would be welcome. It obviously has to do with the fact that two @angular/* modules are included and therefore the app loads neither (or something like that). Yes, I could just use 1.2.7 until there is a "golden standard". But it would also be good to know that this is being addressed (or shown that we are all doing it wrong). So far there is no comment on this thread. Thanks for building such an awesome tool though. It has helped a ton and is really amazing! I also understand that there are priorities (this may not be one). I don't want to sound ungrateful. |
We have also chosen for linking our generic codebase and I totally agree with @axtho that it would be really nice if this works again. I'll stay for now on 1.2.7 I guess, or use aot mode, but it seems like many people have quite a big problem now. Especially because we felt comfortable when all >1.0.0 releases supported this strategy till 1.3.0. CLI self also still provides the documentation on how to use linked modules, but this probably is out of date. I think it can lead people to falsy solutions if this is not addressed, again agree with @axtho. I use CLI from it's beta days and it solved many of our problems, it's an amazing tool and I hope we get someone's explanation on the plans for this. |
Ah, I just found that in v1.5.0-beta.2 --preserve-symlink works for us in JIT mode. So the combination of tssconfig "paths": { "@angular/": [ "../node_modules/@angular/"]} and this flag on ng serve solves the problem for us. |
@ubarevicius so do all versions > 1.2.7 with |
Ah man, need to pay more attention when reading the comments :) thx |
So just for the record: I got it all to work with the latest beta (maybe that is even not necessary). I can confirm the For those still struggling, here is my working setup: note here that the "paths" object goes to the tsconfig of the app which consumes the linked lib (something I was not totally aware of). Check out the core setup with the two tsconfig files (something the yeoman generator did, and which seems to work well). Maybe this will help someone save some time. |
Same as @akash-potdar7. I can load plenty of other MatModule's, but edit: I messed up the import somehow. It works now. Double check your app.module.ts guys |
I had the same problem with a linked lib for angular 5 and this worked for me: https://stackoverflow.com/a/47445313/1438483 |
@amivit I got the same error Just added
in the app module and MatSnackBar in the component the error resolved.. |
|
"compiler.js:15975 Uncaught Error: Unexpected value 'AngularFireDatabase' imported by the module 'AppModule'. Please add a @NgModule annotation." |
Are you still able to reproduce this issue? |
Closing the issue due to inactivity. If the problem still exists in the latest version of the CLI, please open a new issue following the template and providing a minimal demo where we can reproduce it. Thanks! :-) |
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. |
Bug Report or Feature Request (mark with an
x
)Versions.
Repro steps.
Repository https://github.com/ng-select/ng-select
The log given by the failure.
Desired functionality.
I expect to serve linked local library without any errors as it works with -aot mode.
Mention any other details that might be useful.
I get this error only then I'm installig local library from dist folder and only with JIT mode. In package.json I have added
"@ng-select/ng-select": "../dist/"
It works perfectly fine if I install library from npm repository. I tried to add paths to tsconfig as described here https://github.com/angular/angular-cli/wiki/stories-linked-library but it doesn't work for me. I would be very helpful if somebody can look at this issue, I thought something may be wrong with my code somewhere but I suppose everything should work fine in JIT mode if it is working in AOT mode :)
The text was updated successfully, but these errors were encountered: