Module js

https://studyfreinds.22web.org/pro/Download.html

Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of “text/plain”. Strict MIME type checking is enforced for module scripts per HTML spec.
errors.infinityfree.net/errors/404/:1
Failed to load resource: the server responded with a status of 404 ()
Download.html:106 Uncaught ReferenceError: handleFileSelection is not defined
at HTMLInputElement.onchange (Download.html:106:95)

Does infinityfree support module js I mean file with .mjs extension which is running nicely on local machine but not on infinityfree server

I’m afraid not. .mjs files are for Node.js, and InfinityFree only supports client-side Javascript, not server-side. However, it is supported on iFastNet if you upgrade to Premium.

5 Likes

Thanks for your reply But I haven’t installed node.js on my local machine still it works, and I’m using trebedit on chrome os by the way.

And the file I’m using is from PDF.js library which is a client based library to run

If it’s for personal use, use render or vercel to deploy your project. Both supports server-side and static files, provides free subdomain too. Check my website https://uploadspeedcalculator.onrender.com

MJS files are basically just Javascript files, but with a little bit different implication for how they are used in browsers. MJS files can be used with Node.js but can also be used in browsers.

But that’s not really relevant. The important part is that the error message you get refers to our 404 error page, which probably means that the .mjs file being references just can’t be found.

Seeing how your HTML file is called Download.html, please note that our servers, like almost all hosting servers, are case sensitive. So if the file casing is different, that might explain why it works on your own computer but not here.

4 Likes

Thanks for your replies guys but I have renamed the file extension to .js and now it’s working.

Renaming the file to .js may indeed fix it.

But just for completeness sake, it might also be that the server just doesn’t recognize the file type .mjs. To make sure that the server properly identifies the .mjs files, you could try adding the following line to your .htaccess file:

AddType text/javascript .mjs
3 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.