Failed to Load module Script
Any Idea what's the problem with the code that I am trying to run?
This is the problem that occurs, it didn't load the javascript.
Thanks Guys
8 Replies
Show us your loading of the script
I'm assuming you forgot to add the attribute type="text/javascript"
Learning what mime types are isn't talk about much but it's fascinating as the web is built with these namespaces/schemas
for html
For Script
basically this is the filepath
I put this in default.php
web/public/js/script.js is the path
@b1mind
Does script export? Seems like it could be a esm issue? Not sure honestly. Do you have type: module in you package.json too?
What php framework? Build tool etc?
unexpected token '<'it's likely a server error spitting out HTML code instead of that .js file, which would explain the mime type error followed by the "unexpected token '<'". open the URL for the .js file directly in the browser, that'll either show the js code or a server error page. node_modules is not part of your "public" DocumentRoot and wouldn't be deployed. you're likely getting a 404 (html error) instead of the script. your bundler should actually copy that boostrap.js to the web folder as an external resource similar to what you have in the 'assets' folder