[▲ Vercel Community](/) · [Categories](/categories) · [Latest](/latest) · [Top](/top) · [Live](/live)
[Help](/c/help/9)
# Hono Node runtime won't deploy on vercel
679 views · 14 likes · 10 posts
Arpit Jacob (@arpitjacob) · 2024-11-30
I am trying to deploy the `hono` example project with nested routes but I keep getting the error below
`ReferenceError: exports is not defined in ES module scope`
it runs fine locally
Looks like this issue reported here from march hasn't been resolved
https://github.com/orgs/vercel/discussions/6252
I've tested a 2x2x2x2 matrix of factors — JS vs TS, Edge vs Node runtime, dev vs prod, and package.json type: module vs not — and here are the results:
| | Lang | | Runtime | | type:module | | **Dev** | | **Prod** | |
|---|
| | --- | --- | --- | --- | --- | |
| | JS | | Edge | | **type:module** | | ✅ | | ✅ | |
| | JS | | Edge | | – | | ✅ | | ✅ | |
| | JS | | **Node** | | **type:module** | | ✅ | | ✅ | |
| | JS | | **Node** | | — | | ✅ | | ✅ | |
| | **TS** | | Edge | | **type:module** | | ✅ | | ✅ | |
| | **TS** | | Edge | | — | | ✅ | | ✅ | |
| | **TS** | | **Node** | | **type:module** | | ✅ | | ❌ | |
| | **TS** | | **Node** | | — | | ❌ | | ✅ | |
Error details:
* TS/Node/type:module/prod: `ReferenceError: exports is not defined in ES module scope`
* TS/Node/—/dev: `Error: Unexpected token 'export'`
Pauline P. Narvas (@pawlean) · 2024-12-03 · ♥ 2
Hi, Arpit! Welcome to the Vercel Community :smile:
As far as I understand, this error typically occurs when there's a mismatch between CommonJS and ES Module syntax. I have a few suggestions!
1. First, make sure your `package.json` file includes the following:
```json
{
"type": "module"
}
```
This tells Node.js to treat all `.js` files in your project as ES modules.
2. Update your import statements to use ES Module syntax. For Hono, it should look like this:
```javascript
import { Hono } from 'hono'
```
3. If you're using TypeScript, ensure your `tsconfig.json` includes:
```json
{
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "node"
}
}
```
4. If you're using any CommonJS modules in your project, you might need to update them to use ES Module syntax or use dynamic imports.
6. Make sure you're using a recent version of Node.js that fully supports ES Modules (Node.js 14.x or later is recommended).
7. If you're using a bundler like webpack or rollup, ensure it's configured to handle ES Modules correctly.
If you're still encountering issues after making these changes, it would be helpful to see more of your code, particularly the file where the error is occurring and any configuration files you're using.
Arpit Jacob (@arpitjacob) · 2024-12-03
Hi Paulina, I've already done these things. I don't think you read through my explanation, I've linked through the orignal post where he does a much better job of explaining the issue. . There is even a table which points on which instance this doesn't work.
This is bug on your deployment system.
Pauline P. Narvas (@pawlean) · 2024-12-03 · ♥ 1
I saw your error and jumped to solution-ising! Apologies :pray:
It would be helpful to get a reproducible example from you as well, Arpit. I will do the same :slight_smile: then pass it on to the team!
Amy Egan (@amyegan) · 2024-12-03
I found the repro buried in the original thread and passed it along to the team. Thanks for reporting this again.
It only works for me if I build from my local copy and [deploy the prebuilt project](https://vercel.com/docs/cli/deploying-from-cli#deploying-from-local-build-prebuilt). So that's a possible workaround until we can identify the cause and reach a more stable solution.
We'll keep you updated here as we learn more from the deployment experts
Amy Egan (@amyegan) · 2024-12-04 · ♥ 1
The team just got back to me with the solution. The example repo you shared already had `"type": "module"` in the the `package.json`, but no `tsconfig`.
I copied Pauline's [recommended config](https://community.vercel.com/t/hono-node-runtime-wont-deploy-on-vercel/2612/2) from above and my deployment started working as expected. Please make sure you have the project setup so TS files output ES instead of CommonJS. Then the error will go away :slightly_smiling_face:
Jacob Paris (@jacobparis) · 2024-12-09 · ♥ 3
I just ran into this issue myself, the culprit is that the Hono starter has the tsconfig in the .vercelignore file so even with the correct settings, it won't work when you deploy
That's also why your workaround by building locally worked, since the tsconfig was present in your local system even if it wasn't being deployed
I've made a PR to fix the vercelignore file
https://github.com/vercel/hono-starter/pull/2
Arpit Jacob (@arpitjacob) · 2024-12-09 · ♥ 3
Ah that makes sense, I removed it from the `.vercelignore` it working for me now :+1: thank you
Amy Egan (@amyegan) · 2024-12-09 · ♥ 2
@jacobparis Good catch! Thanks for the PR :smile:
Anthony Shew (@anthony-shew) · 2025-08-01 · ♥ 2
Hey, Arpit. Just wanted to let you know that we shipped zero-configuration Hono to Vercel today.
More info here: https://community.vercel.com/t/introducing-zero-configuration-hono-backends/17619