Error after adding Tailwind to Vite +Typescript + JS Project

Hey guys,

I am experiencing the following error after adding Tailwind to my project and I’m not sure how to solve it? Can anyone help me? Thanks

Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of “video/mp2t”. Strict MIME type checking is enforced for module scripts per HTML spec.

try vite for installing “react” with "type script with this npm create vite@latest and then simply add tailwind to that mix, read tailwind docs for installation with “vite”

happy coding :slight_smile:

Thank you but I am not using React in my project. I created a a project using Vite and I chose Vanilla JS and Typescript as the options. I have also already installed tailwind. I have the error in the console and I can see that my styling is viewable but I get the error in the console.

That error sounds completely unrelated. I don’t know why there would be errors about MIME types for a video as you have no such code in your project.


You need to install postcss and autoprefixer as well.

Run npx tailwindcss init -p again after you have installed the dependencies (it will keep your current config).

You need to import the input.css not the styles.css

I was able to solve my issue. I did everything that @lasjorg recommended but also changed my script tag in my HTML to /dist/assets/whatever.js instead of /src/main.ts.

Thanks everyone!

UPDATE

The above didn’t actually work. I am still getting the same error in the console.

UPDATE 2

I solved my issue and it was me being dumb :weary:
I was using Live Server instead of using the url that was given to me after running npm run dev to view my project…Live Server is unable to read .ts files and Live Server needs those to be converted to .js…the post underneath helped me realize what I was doing wrong :melting_face:

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