Skip to content
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

Hono Netlify Adapter not working out of the box + Solution #3891

Open
pkorac opened this issue Feb 4, 2025 · 2 comments
Open

Hono Netlify Adapter not working out of the box + Solution #3891

pkorac opened this issue Feb 4, 2025 · 2 comments
Labels

Comments

@pkorac
Copy link

pkorac commented Feb 4, 2025

What version of Hono are you using?

4.3.11

What runtime/platform is your app running on? (with version if possible)

Netlify

What steps can reproduce the bug?

When using the npm create hono@latest command to create an app for deployment to Netlify, the app doesn’t build properly.

Running netlify dev results in a series of errors:

◈ Failed to run Edge Function index:
TypeError: Import 'https://registry-staging.deno.com/@hono/hono/meta.json' failed: error sending request for url (https://registry-staging.deno.com/@hono/hono/meta.json): error trying to connect: dns error: failed to lookup address information: nodename nor servname provided, or not known
    at file:///Users/peter/Documents/explorations/hononetlify/netlify/edge-functions/index.ts:1:22
    at async file:///Users/peter/Documents/explorations/hononetlify/.netlify/edge-functions-serve/dev.js:7:35 {
  code: "ERR_MODULE_NOT_FOUND"
}
TypeError: Import 'https://registry-staging.deno.com/@hono/hono/meta.json' failed: error sending request for url (https://registry-staging.deno.com/@hono/hono/meta.json): error trying to connect: dns error: failed to lookup address information: nodename nor servname provided, or not known
    at file:///Users/peter/Documents/explorations/hononetlify/netlify/edge-functions/index.ts:1:22
    at async file:///Users/peter/.nvm/versions/node/v22.4.1/lib/node_modules/netlify-cli/node_modules/@netlify/edge-bundler/deno/config.ts:12:10 {
  code: "ERR_MODULE_NOT_FOUND"
}

Solution (what worked for me)

Use the URL method of importing packages instead of jsr.

Replace the

import { Hono } from 'jsr:@hono/hono'
import { handle } from 'jsr:@hono/hono/netlify'

with

import { Hono } from "https://deno.land/x/[email protected]/mod.ts";
import { handle } from "https://deno.land/x/[email protected]/adapter/netlify/index.ts";

Or with

import { Hono } from "https://esm.sh/jsr/@hono/hono@4";
import { handle } from "https://esm.sh/jsr/@hono/hono/netlify";

Hope this helps

What is the expected behavior?

◈ Static server listening to 3999

   ┌─────────────────────────────────────────────────┐
   │                                                 │
   │   ◈ Server now ready on http://localhost:8888   │
   │                                                 │
   └─────────────────────────────────────────────────┘

◈ Loaded edge function index

What do you see instead?

◈ Failed to run Edge Function index:
TypeError: Import 'https://registry-staging.deno.com/@hono/hono/meta.json' failed: error sending request for url (https://registry-staging.deno.com/@hono/hono/meta.json): error trying to connect: dns error: failed to lookup address information: nodename nor servname provided, or not known
    at file:///Users/peter/Documents/explorations/hononetlify/netlify/edge-functions/index.ts:1:22
    at async file:///Users/peter/Documents/explorations/hononetlify/.netlify/edge-functions-serve/dev.js:7:35 {
  code: "ERR_MODULE_NOT_FOUND"
}
TypeError: Import 'https://registry-staging.deno.com/@hono/hono/meta.json' failed: error sending request for url (https://registry-staging.deno.com/@hono/hono/meta.json): error trying to connect: dns error: failed to lookup address information: nodename nor servname provided, or not known
    at file:///Users/peter/Documents/explorations/hononetlify/netlify/edge-functions/index.ts:1:22
    at async file:///Users/peter/.nvm/versions/node/v22.4.1/lib/node_modules/netlify-cli/node_modules/@netlify/edge-bundler/deno/config.ts:12:10 {
  code: "ERR_MODULE_NOT_FOUND"
}

Additional information

I solved my issue by using one of the url importing methods https://deno.land/x/hono, there are others like esm https://esm.sh/jsr/@hono/hono@4, and perhaps the create command + example could show one of them.
Appreciate this is specific to deploying on Netlify, but that's what the create template using Netlify suggest user would be able to do.

@pkorac pkorac added the triage label Feb 4, 2025
@yusukebe
Copy link
Member

Hi @pkorac

Thank you for the issue. This is not in the scope of honojs/hono, but the starter issue.

https://github.com/honojs/starter

I have never investigated but I think the Netlify does not support JSR.

@pkorac
Copy link
Author

pkorac commented Feb 10, 2025

Hi @yusukebe thanks for the pointer. I'll create an issue over there.

@yusukebe yusukebe added not bug and removed triage labels Feb 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants