title: Upgrade to Angular 12 - NullInjectorError: No provider for InjectionToken
body: <p>Original implementation was based on the pattern described in</p>
  <p><a href="https://shashankvivek-7.medium.com/forroot-injectiontoken-in-action-angular-c2bab9959207" rel="nofollow noreferrer">https://shashankvivek-7.medium.com/forroot-injectiontoken-in-action-angular-c2bab9959207</a></p>
  <p>It was working until I upgraded it to angular 12. After the upgrade  I kept getting the NullInjector error. Unable to resolve it anyway, I ended up creating two vanilla simple projects for Angular 11 and 12 each. Additionally, I moved the token provider from the project module to the appmodule.</p>
  <p>Angular 12 Sample
  <a href="https://drive.google.com/file/d/1lE8RL6s8L9n6zQYqVOaLqMW9ikMfMgSu/view?usp=sharing" rel="nofollow noreferrer">https://drive.google.com/file/d/1lE8RL6s8L9n6zQYqVOaLqMW9ikMfMgSu/view?usp=sharing</a></p>
  <p>Angular 11 Sample
  <a href="https://drive.google.com/file/d/1HxhCz3i5nmrK8Zj0eddTlk8zz-29lwlh/view?usp=sharing" rel="nofollow noreferrer">https://drive.google.com/file/d/1HxhCz3i5nmrK8Zj0eddTlk8zz-29lwlh/view?usp=sharing</a></p>
  <p>The angular 11 version works (even prod mode), but the other version runs into the same error.</p>
  <p><a href="https://i.stack.imgur.com/0kwus.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0kwus.png" alt="Injector Error" /></a></p>
  <p>This is what it looks like inside the debugger</p>
  <p><a href="https://i.stack.imgur.com/Gss7o.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Gss7o.png" alt="Debugger" /></a></p>
  <p>It looks like the line</p>
  <pre><code>let record = this.records.get(token);
  </code></pre>
  <p>in R3Injector.get always fails to find the record by the token, even though the record exists in the list of records, as can be seen in the image (index 58). It is because of this that a duplicate record at index 78, gets added. The key and the token parameter seem to be identical.</p>
  <p>I'm unable to find any definitive information about it, or a way to fix it.</p>