When I try to load my Angular Project as an Electron app, I get the following error:
Failed to load module script: The server responded with a non-JavaScript MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec.**
I used this tutorial to create the application and now I'm trying to add some components. So my code is similar to the one supplied in the tutorial I just added the Homecomponent
with ng generate
.
https://malcoded.com/posts/angular-desktop-electron/
The solution that was given in the tutorials comment section isn't working for me or maybe I'm doing something wrong.
I faced the same issue recently and after some research discovered this error is caused by Angular 8 not adding MIME types to Typescript files converted to js. If you ng serve
and inspect the page, you'll notice the js scripts have a type of "module"
, this confuses Electron. There are several workarounds, as discussed in this GitHub issue.
What worked for me was simply changing the "target"
property in the "compilerOptions"
of tsconfig.json
to "es5"
.
I hope someone finds this useful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With