3

As Chrome supports EcmaScript 6 modules now (Medium article), I thought I could develop a demo app using the export and import syntax. However, this only works when uploading my code to a server - which is quite annoying when developing. Other developers have faced similar problems and recommend using Chrome with --disable-web-security (Disable same origin policy in Chrome) or --allow-file-access-from-files (How to launch html using Chrome at “--allow-file-access-from-files” mode?). However, I now get the error

Failed to load module script: The server responded with a non-JavaScript MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec.

And I can't seem to find a way to turn off Strict MIME type checking in Chrome (my version is 64.0.3282.140).

So, this is my question: How can I develop ES6 modules locally with Chrome (this must be possible, surely)?

M_F
  • 386
  • 4
  • 11
  • 2
    Just use a local development server...? – Michał Perłakowski Feb 12 '18 at 17:40
  • Yes, I could, but isn't there a simpler way? – M_F Feb 12 '18 at 17:42
  • 5
    That *is* the simple way. –  Feb 12 '18 at 17:42
  • Okay. But I still think it should be possible to just test your code locally without using a development server. I'll do it, though, if there's no other way. – M_F Feb 12 '18 at 17:44
  • I didn't say there isn't another way. I said there's no simpler way. Just use NodeJS to serve your site. It's *far better* than serving files locally. –  Feb 12 '18 at 17:48
  • Have a look at [`lite-server`](https://www.npmjs.com/package/lite-server) install it globally and run it in the root of your project. That should be good enough as a local server with auto reload. – realappie Feb 12 '18 at 18:10
  • There are enough server packages available (I am using `http-server` right now), it's really no problem to run one. I just wanted to know if there's a way without using a development server. – M_F Feb 12 '18 at 18:15

0 Answers0