-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
After using vue-router, there is an error in packaging and running # Failed to load module script: The server responded with a non-JavaScript MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec. #863
Comments
Can you give a reproduction? It looked very weird.This should hasn't |
I found the problem Encapsulating defineAsyncComponent as a function will cause the component to not be read, so there is no abnormality when developing, but the vue file will not be packaged when packaging The error is function loadView(view) {
return defineAsyncComponent(() => import(`../views/${view}.vue`));
}
routes: [
{
path: "/",
name: "Home",
component: loadView('Home')
}
] This will cause the corresponding vue file to not be packaged when packaging |
@underfin Thank you! |
@nshusr hey can you tell me how you solved this? Does |
Oh nevermind, I guess a loop around it causes the same problem. |
Write each route import separately and it will work fine It seems that the imported components cannot be written as functions yet can use routes: [
{
path: "/",
name: "Home",
component: defineAsyncComponent(() => import('../views/Home.vue'));
},
{
path: "/about",
name: "About",
component: defineAsyncComponent(() => import('../views/About.vue'));
}
] |
@nshusr yeah figured it out. thanks though! |
#93 Describe the bug
After using vue-router and build, there will be errors when and run in nginx.
Failed to load module script: The server responded with a non-JavaScript MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.
Tried Nginx to add type information to js files but the same error still occurs
System Info
vite
version: 1.0.0-rc.4vue
version (fromyarn.lock
orpackage-lock.json
) 3.0.0@vue/compiler-sfc
version 3.0.0The text was updated successfully, but these errors were encountered: