Replies: 1 comment
-
Any updates on this topic are highly appreciated! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I’m trying to create a simple Vercel function running on a node environment using the Hono framework.
Using these steps: https://hono.dev/docs/getting-started/vercel
`npm create hono@latest my-app
npm i`
instead of “npm run dev” I must call “npm run start,” not according to Hono documentation, strange.
npm i @hono/node-server
replacing handle from
import { handle } from 'hono/vercel’
toimport { handle } from “@hono/node-server/vercel”;
Creating .env file and adding:
NODEJS_HELPERS=0
Also adding to package.json
“type”: “module”
starting the server:
npm run start
opening the browser: http://localhost:3000/api and seeing “{“message”:“Hello Hono!”}”
Everything looks great.
Now I’m adding the test.ts file into /api
Contents:
export const myName = "Bob";
In /api/index.ts changing
return c.json({ message: "Hello Hono!" });
to
return c.json({ message:
Hello ${myName}});
and adding
import { myName } from "./test";
starting the server:
npm run start
no errors
Opening in browser: http://localhost:3000/api
and getting the error: Error: Cannot find module ‘…\test\vercel\my-app\api\test’ imported from …\test\vercel\my-app\api\index.ts
Just stuck for a whole day and don't know what to do next.
Any help is greatly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions