Repository navigation
InjectorError trying to inject Injector into AOT-compiled library when using JIT for app #20102
Description
Activity
Hmm, that's weird.
Just tried following the exact repro steps again from start and I'm still getting the error.
What version of node did you use?Using dist for lib is invalid since Angular CLI will clear it each time, just change it to lib could make it runnable.
Could you explain what you mean by this? angular-cli is only used in the app, the lib uses plain ngc.
_ _ ____ _ ___ / \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _| / △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | | / ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | | /_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___| |___/ Angular CLI: 1.5.0 Node: 6.11.2 OS: darwin x64 Angular: 5.0.0 ... animations, common, compiler, compiler-cli, core, forms ... http, language-service, platform-browser ... platform-browser-dynamic, router @angular/cli: 1.5.0 @angular-devkit/build-optimizer: 0.0.32 @angular-devkit/core: 0.0.20 @angular-devkit/schematics: 0.0.35 @ngtools/json-schema: 1.1.0 @ngtools/webpack: 1.8.0 @schematics/angular: 0.1.0 typescript: 2.4.2 webpack: 3.8.1Angular CLI will remove
distfolder whenever you runng serve(see angular/angular-cli#4293), so your app can never start successfully.Ah, I think now I understand what you did.
In the README, by "Then checkout branch app INTO ANOTHER DIRECTORY and follow README instructions there.", I meant cloning theappbranch somewhere else so you have the lib in one directory and the app in another. This way, they can beyarn linked together without interference.
Could you whether you can reproduce the issue that way?Oh, I see, then your problem should be lacking of
--preserve-symlinks(see angular/angular-cli#6460) in your scripts.Your lib would importing a different Angular library, meaning you'll have two sets of Angular framework in your app.
But it won't affect the real use case (normal npm install).
Reacted by Tim Seckinger, Matt Hegarty, Doocaat, malytskyy, andorkerti and kk21717Ok, that seems to have solved it.
Totally didn't expect this to be a problem caused by linking instead of installing the library, especially because importing and applying the module & directive worked and only the injection didn't, and it only happened in JIT mode.
Thank you very much!angular-automatic-lock-bot commented
on Sep 12, 2019 More actionsThis issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.
- locked and limited conversation to collaborators
on Sep 12, 2019



I'm submitting a...
Current behavior
A library with a directive that requires injection of
Injectoris AOT-compiled and distributed with metadata.An app imports the library's module and applies the directive to an element.
Running the app with
ng serve --aotworks fine, theInjectoris injected into the library directive.Running the app with
ng serve(JIT) results in error on page load:Note that this is not specific to
Injector, trying to inject e.g.IterableDifferscauses the same problem.Expected behavior
The app works with both JIT and AOT.
Minimal reproduction of the problem with instructions
https://github.com/jeysal/ng5-jit-inj-repro
Follow the instructions in the readme on
masterto reproduce.Branch
mastercontains the library (with very basic build setup).Branch
appcontains the app (generated by angular-cli).Environment