question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ERROR: [plugin: deno] Unhandled media type Json.

See original GitHub issue

I’m using a deno library that imports a JSON file with:

import countries from "https://cdn.jsdelivr.net/gh/umpirsky/country-list@2.0.6/data/en_US/country.json" assert { type: "json" };

This is happening in the code for an island, what I get in the console is:

Loading module from “http://localhost:8000/_frsh/js/63eb35c3-6547-4f71-9fc2-b111894c1374/island-playground.js” was blocked because of a disallowed MIME type (“text/html”)

And going to the URL in this error gives me:

An error occured during route handling or page rendering.

Error: Build failed with 2 errors:
deno:https://deno.land/x/duckling@v0.0.4/src/Location.ts:11:22: ERROR: [plugin: deno] Unhandled media type Json.
deno:https://deno.land/x/duckling@v0.0.4/src/URL.ts:19:17: ERROR: [plugin: deno] Unhandled media type Json.
    at failureErrorWithLog (https://deno.land/x/esbuild@v0.14.39/mod.js:1572:15)
    at https://deno.land/x/esbuild@v0.14.39/mod.js:1218:28
    at runOnEndCallbacks (https://deno.land/x/esbuild@v0.14.39/mod.js:1001:63)
    at buildResponseToResult (https://deno.land/x/esbuild@v0.14.39/mod.js:1216:7)
    at https://deno.land/x/esbuild@v0.14.39/mod.js:1325:14
    at https://deno.land/x/esbuild@v0.14.39/mod.js:633:9
    at handleIncomingPacket (https://deno.land/x/esbuild@v0.14.39/mod.js:730:9)
    at readFromStdout (https://deno.land/x/esbuild@v0.14.39/mod.js:599:7)
    at https://deno.land/x/esbuild@v0.14.39/mod.js:1846:11

So my question is, are JSON imports not allowed in islands? And if they’re allowed - what am I doing wrong? The library should work as expected, at least it does when I run the test suites.

Thanks

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
lucacasonatocommented, Jul 31, 2022

This is fixed in Fresh 1.0.2.

1reaction
lucacasonatocommented, Jul 30, 2022

That is likely a different bug - you are probably importing JSON in the form of import { foo } from "./data.json" assert { type: "json" } instead of import data from “./data.json” assert { type: “json” }`. JSON imports only allow importing the entire value as a default import.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Support json media type for importing modules #10748 - GitHub
package.json' but this fails: error: An unsupported media type was attempted to be imported as a module. Specifier: https://raw.gi...
Read more >
2.x API - Deno
Returns middleware that only parses JSON and only looks at requests where the Content-Type header matches the type option. This parser accepts any...
Read more >
Unhandled rejection: Deno's equivalent of Node.js - Medium
In this article, we'll go over Deno's equivalent of Node.js's global error handler: unhandledRejection. In this particular case, it'd be useful ...
Read more >
SyntaxError: Cannot use import statement outside a module
In the nearest parent package.json file, add the top-level "type" field with a value of "module" . This will ensure that all .js...
Read more >
Errors - Fastify
¶Errors In Fastify Lifecycle Hooks And A Custom Error Handler ... Body cannot be empty when content-type is set to application/json .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found