Deploying a web app using Vite, I am unable to deploy the .js file. "<script src="/index.js"> in "/index.html" can't be bundled without type="module"
Asked Answered
S

1

9

When Deploying a web app using Vite, I am unable to deploy the .js file. Getting the below issue.

$ vite build
vite v2.8.6 building for production...
**\<script src="/index.js"\> in "/index.html" can't be bundled without type="module" attribute**
transforming...

I cannot use in script type=module as I have no import of code to be done. If I use then error is coming.

If anyone can help.

I tried using script type=module but error is coming. Is there any way I can deploy with Vite without using type=module ?

Saxena answered 24/3, 2022 at 6:49 Comment(2)
Could you provide some more information with what kind of errors you get when using type="module"? Generally, errors that that attribute causes should not be too hard to fix.Junko
I have this problem too. I'm trying to include some old, pre-module JS libraries on the page that assume they'll be included using a "classic script" (expect a global this to equal window, expect top level var declarations to be global properties on window, etc). I don't want to edit to those libraries to make them work with type="module", they do their job just fine when included via a classic <script>.Payday
G
0

You can use the public directory.

you can copy your index.js file there

Gentleness answered 8/6, 2023 at 13:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.