defineEventHandler() is undefined in ~/server/api on Stackblitz
See original GitHub issueEnvironment
Stackblitz starter template
Nuxt CLI v3.0.0-rc.2 (and Nuxt CLI v3.0.0-rc.1) RootDir: /home/projects/nuxt-starter-sh8cyl 10:06:48 Nuxt project info: 10:06:48
- Operating System:
Linux - Node Version:
v16.14.2 - Nuxt Version:
3.0.0-rc.2 - Package Manager:
npm@7.17.0 - Builder:
vite - User Config:
- - Runtime Modules:
- - Build Modules:
-
Reproduction
https://stackblitz.com/edit/nuxt-starter-sh8cyl?file=server/api/hello.ts
Describe the bug
The defineEventHandler() function used in the ~/server/api folder is marked as undefined.
Error message:
Cannot find name 'defineEventHandler'.(2304) any
Additional context
As stated in the documentation,
Nuxt exposes every auto-import with the #imports alias that can be used to make the import explicit if needed
import { defineEventHandler } from '#import'; returns an error too: Cannot find module '#import' or its corresponding type declarations.
Logs
No response
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top Related StackOverflow Question
managed to get it working by adding h3 as a dependency and calling it explicitly:
in
server/api/middleware/log.jsI believe this is caused by the fact that stackblitz hides the
.nuxtfolder. Let’s see what the team there might be able to do.