Solution:
The <script> tag that loads the Angular bundles of JavaScript must come after the <app-root> element in the HTML. JavaScript is executed once it is loaded and if the rest of the Html hasn’t been loaded, then the selector will fail to find <app-root>.
If you can not move the <script> tag, then you can use the defer attribute to run the JavaScript after the Html document is read.
<script src="javascript.js" defer></script>