og-image icon indicating copy to clipboard operation
og-image copied to clipboard

Windows - Failed to load module script: Expected JavaScript module in index.js

Open whoami15 opened this issue 3 years ago • 15 comments

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.

whoami15 avatar Dec 24 '21 02:12 whoami15

"Debugger attached" sounds like the debugger might be interfering.

Does it work without that?

styfle avatar Dec 27 '21 15:12 styfle

@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

whoami15 avatar Dec 28 '21 05:12 whoami15

Can you share the source code?

Specifically vercel.json

styfle avatar Dec 28 '21 18:12 styfle

here's my vercel.json

{
  "regions": ["all"],
  "functions": {
    "api/**": {
      "memory": 1024
    }
  },
  "rewrites": [
    { "source": "/(.+)", "destination": "/api" }
  ]
}

whoami15 avatar Dec 29 '21 05:12 whoami15

Did you run yarn install?

styfle avatar Dec 29 '21 19:12 styfle

Yes, I did. I also tried cloning the repo again and followed the same steps.

whoami15 avatar Dec 30 '21 04:12 whoami15

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

whoami15 avatar Dec 30 '21 04:12 whoami15

Do you have a dist directory with the file dist/web/index.js?

What is the content of that file?

styfle avatar Jan 01 '22 20:01 styfle

Yes, I have that file, dist/web/index.js.

whoami15 avatar Jan 02 '22 06:01 whoami15

Which OS are you using?

styfle avatar Jan 03 '22 15:01 styfle

Sorry, I forgot to mention above, I'm using Windows 10.

whoami15 avatar Jan 04 '22 06:01 whoami15

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?

styfle avatar Jan 04 '22 19:01 styfle

I'll try it, thanks @styfle

whoami15 avatar Jan 05 '22 04:01 whoami15

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?

georgeosutton avatar Jul 29 '22 18:07 georgeosutton

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.

Talha-1010 avatar Aug 08 '22 10:08 Talha-1010

Thanks @TooTallNate 🎉

whoami15 avatar Nov 16 '22 01:11 whoami15