0

My frontend is Vue.js

and I build it

and run it with express.js

but I get this error

index.9235fea6.js:1 Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.

I don't know what to do

1 Answer 1

0

There are typically two ways for fixing it:

  1. Server routing

    In your Express server, you should have something like:

    app.use(express.static('path-to-your-dist-folder'));
    
  2. Correct file path If Express can't find your index.9235fea6.js file, it might be returning an HTML error page, which is causing the problem

1
  • app.get('*', (req, res) => { res.sendFile(path.join(__dirname + '/dist/index.html')); }); If you write this, you will get the same error as in the text. and if you don't write it, the page will keep loading. Commented Sep 4 at 10:41

Not the answer you're looking for? Browse other questions tagged or ask your own question.