Workaround is to add empty script in head section <script></script> or any other script (if all of your scripts are in body).
We have encountered similiar problem recently when we migrated our repo to webpack 5.
This piece of code takes first script in document, which has type != dojo:
var ya = x.getElementsByTagName("script");
for (d = 0; !Oa; )
/^dojo/.test((e = ya[d++]) && e.type) || (Oa = e);
Then this script is used in injectUrl method to get parentNode and then insert esri scripts before it. In our case sometimes dynamic chunk script (added temporarily to html document head) was selected. But since dynamic chunks are removed from DOM (parent node becomes undefined) code fails and throws error.