og-image
og-image copied to clipboard
Windows - Failed to load module script: Expected JavaScript module in index.js
I'm getting an error below after I ran vercel dev
in my Local environment.
Error in console, also uploaded a screenshot.
index.js:1 Failed to load module script: Expected a JavaScript module script
but the server responded with a MIME type of "image/png".
Strict MIME type checking is enforced for module scripts per HTML spec.
This is my terminal result after I ran vercel dev
Debugger attached.
Vercel CLI 23.1.2 dev (beta) — https://vercel.com/feedback
> Creating initial build
Debugger attached.
Running "yarn run build"
Debugger attached.
yarn run v1.22.17
$ tsc -p api/tsconfig.json && tsc -p web/tsconfig.json
Debugger attached.
Waiting for the debugger to disconnect...
Debugger attached.
Waiting for the debugger to disconnect...
Done in 11.89s.
Waiting for the debugger to disconnect...
> Success! Build completed
> Ready! Available at http://localhost:3000
Debugger attached.
HTTP /dist/web/index.js
I did follow the steps here, and haven't made changes in the files yet.
"Debugger attached" sounds like the debugger might be interfering.
Does it work without that?
@styfle , here without debugger attached. I'm still getting the same output as shown in the screenshot.
Vercel CLI 23.1.2 dev (beta) — https://vercel.com/feedback
> Creating initial build
Running "yarn run build"
yarn run v1.22.17
$ tsc -p api/tsconfig.json && tsc -p web/tsconfig.json
Done in 6.58s.
> Success! Build completed
> Ready! Available at http://localhost:3000
Can you share the source code?
Specifically vercel.json
here's my vercel.json
{
"regions": ["all"],
"functions": {
"api/**": {
"memory": 1024
}
},
"rewrites": [
{ "source": "/(.+)", "destination": "/api" }
]
}
Did you run yarn install
?
Yes, I did. I also tried cloning the repo again and followed the same steps.
index.js:1 Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "image/png". Strict MIME type checking is enforced for module scripts per HTML spec.
it turns out that http://localhost:3000/dist/web/index.js
is returning an image containing vercel-triangle-black.svg
and a text of dist/web/index.js
Do you have a dist
directory with the file dist/web/index.js
?
What is the content of that file?
Yes, I have that file, dist/web/index.js.
Which OS are you using?
Sorry, I forgot to mention above, I'm using Windows 10.
I don't have Windows machine accessible today but I can try it out next week to see if it reproduces on Windows.
In the meantime, you could try Linux or macOS and see if it works?
I'll try it, thanks @styfle
I don't have Windows machine accessible today but I can try it out next week to see if it reproduces on Windows.
In the meantime, you could try Linux or macOS and see if it works?
I'm getting the same issue when attempting to run locally on Windows 10 & 11. Were you able to reproduce the issue?
Getting the same issue on "node": "16.15.0"
, Vercel CLI 27.3.7
, Windows 10 Pro version : 21H2
and yarn run v1.22.19
.
Thanks @TooTallNate 🎉