-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Description
Describe the bug
I am trying to use rpc with hono. The following is my folder structure.
.
├── bun.lock
├── frontend
│ ├── bun.lock
│ ├── components.json
│ ├── dist
│ │ ├── assets
│ │ │ ├── index-Bbk2uyJO.js
│ │ │ └── index-C1mO6vrr.css
│ │ ├── index.html
│ │ └── vite.svg
│ ├── eslint.config.js
│ ├── index.html
│ ├── package.json
│ ├── public
│ │ └── vite.svg
│ ├── README.md
│ ├── src
│ │ ├── App.css
│ │ ├── App.tsx
│ │ ├── assets
│ │ │ └── react.svg
│ │ ├── components
│ │ │ └── ui
│ │ │ ├── button.tsx
│ │ │ └── card.tsx
│ │ ├── lib
│ │ │ ├── api.ts
│ │ │ └── utils.ts
│ │ └── main.tsx
│ ├── tsconfig.app.json
│ ├── tsconfig.json
│ ├── tsconfig.node.json
│ └── vite.config.ts
├── package.json
├── README.md
├── server
│ ├── app.ts
│ ├── index.ts
│ └── routes
│ └── expenses.ts
└── tsconfig.json
The app was working fine until, I tried to use rpc and import the hono client. then I got the following in my terminal
9:02:33 AM [vite] Internal server error: Failed to resolve import "@server/app" from "src/lib/api.ts". Does the file exist?
Plugin: vite:import-analysis
File: /home/shojib116/code/hono-practice/frontend/src/lib/api.ts:1:29
1 | import "@server/app";
| ^
2 | import { hc } from "hono/client";
3 | const client = hc("/");
at _formatLog (/home/shojib116/code/hono-practice/frontend/node_modules/vite/dist/node/chunks/node.js:30669:43)
at error (/home/shojib116/code/hono-practice/frontend/node_modules/vite/dist/node/chunks/node.js:30666:14)
at processTicksAndRejections (native)
9:02:33 AM [vite] (client) Pre-transform error: Failed to resolve import "@server/app" from "src/lib/api.ts". Does the file exist?
Plugin: vite:import-analysis
File: /home/shojib116/code/hono-practice/frontend/src/lib/api.ts:1:29
1 | import "@server/app";
| ^
2 | import { hc } from "hono/client";
3 | const client = hc("/");
this is part of my tsconfig.json
"compilerOptions": { "baseUrl": ".", "paths": { "@/*": ["./src/*"], "@server/*": ["../server/*"], } }
this is part of my vite.config.ts
resolve: { alias: { "@": path.resolve(import.meta.dirname, "./src"), "@server": path.resolve(import.meta.dirname, "./server"), }, },
Reproduction
https://github.com/shojib116/hono-expense-tracker
Steps to reproduce
No response
System Info
System:
OS: Linux 6.8 Linux Mint 22.1 (Xia)
CPU: (16) x64 12th Gen Intel(R) Core(TM) i5-1240P
Memory: 5.50 GB / 15.36 GB
Container: Yes
Shell: 5.9 - /usr/bin/zsh
Binaries:
Node: 22.17.0 - /home/shojib116/.nvm/versions/node/v22.17.0/bin/node
npm: 11.6.0 - /home/shojib116/.nvm/versions/node/v22.17.0/bin/npm
pnpm: 10.18.3 - /home/shojib116/.local/share/pnpm/pnpm
bun: 1.2.20 - /home/shojib116/.bun/bin/bun
Deno: 2.4.3 - /home/shojib116/.deno/bin/deno
Browsers:
Brave Browser: 142.1.84.139
Firefox: 145.0
Firefox Developer Edition: 145.0
npmPackages:
@vitejs/plugin-react: ^5.1.0 => 5.1.0
rolldown-vite: 7.2.2Used Package Manager
bun
Logs
Click to expand!
vite:resolve 3.54ms /home/shojib116/code/hono-practice/frontend/server/app -> null +2ms
vite:resolve 3.62ms @server/app -> /home/shojib116/code/hono-practice/frontend/server/app +0ms
9:14:46 AM [vite] Internal server error: Failed to resolve import "@server/app" from "src/lib/api.ts". Does the file exist?
Plugin: vite:import-analysis
File: /home/shojib116/code/hono-practice/frontend/src/lib/api.ts:1:29
1 | import "@server/app";
| ^
2 | import { hc } from "hono/client";
3 | const client = hc("/");
at _formatLog (/home/shojib116/code/hono-practice/frontend/node_modules/vite/dist/node/chunks/node.js:30669:43)
at error (/home/shojib116/code/hono-practice/frontend/node_modules/vite/dist/node/chunks/node.js:30666:14)
at processTicksAndRejections (native)
vite:time 15.50ms /src/lib/api.ts +2ms
9:14:46 AM [vite] (client) Pre-transform error: Failed to resolve import "@server/app" from "src/lib/api.ts". Does the file exist?
Plugin: vite:import-analysis
File: /home/shojib116/code/hono-practice/frontend/src/lib/api.ts:1:29
1 | import "@server/app";
| ^
2 | import { hc } from "hono/client";
3 | const client = hc("/");
vite:import-analysis 0.14ms [no imports] node_modules/.vite/deps/hono_client.js?v=e8673378 +4ms
vite:transform 4.97ms [skipped] /node_modules/.vite/deps/hono_client.js?v=e8673378 +3ms
vite:load 8.15ms [fs] /src/lib/utils.ts +9ms
vite:resolve 0.26ms clsx -> /home/shojib116/code/hono-practice/frontend/node_modules/.vite/deps/clsx.js?v=e8673378 +12ms
vite:resolve 0.34ms tailwind-merge -> /home/shojib116/code/hono-practice/frontend/node_modules/.vite/deps/tailwind-merge.js?v=e8673378 +0ms
vite:optimize-deps load /home/shojib116/code/hono-practice/frontend/node_modules/.vite/deps/clsx.js +15ms
vite:optimize-deps load /home/shojib116/code/hono-practice/frontend/node_modules/.vite/deps/tailwind-merge.js +1ms
vite:import-analysis 1.07ms [2 imports rewritten] src/lib/utils.ts +10ms
vite:transform 5.89ms /src/lib/utils.ts +10ms
vite:load 0.49ms [plugin] /node_modules/.vite/deps/clsx.js?v=e8673378 +6ms
vite:load 0.57ms [plugin] /node_modules/.vite/deps/tailwind-merge.js?v=e8673378 +0ms
vite:import-analysis 0.04ms [no imports] node_modules/.vite/deps/clsx.js?v=e8673378 +0ms
vite:transform 0.37ms [skipped] /node_modules/.vite/deps/clsx.js?v=e8673378 +0ms
vite:import-analysis 0.31ms [no imports] node_modules/.vite/deps/tailwind-merge.js?v=e8673378 +1ms
vite:transform 0.96ms [skipped] /node_modules/.vite/deps/tailwind-merge.js?v=e8673378 +1ms
vite:cache [304] /src/lib/utils.ts +93ms
vite:time 0.13ms /src/lib/utils.ts +13ms
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.