Reputation: 41
How can I use dynamic import in nuxt 3 (nitro)?
src/server/api/urls.ts:
This method works
export default defineEventHandler(async event => {
const module = await import('../../../utils/transliterate')
return []
})
But if I move the string into a separate variable, I get the following error:
export default defineEventHandler(async event => {
const path = '../../../utils/transliterate'
const module = await import(path)
return []
})
Unknown file extension ".ts" for /mnt/projects/projects/.../src/utils/transliterate.ts
I tried to set absolute paths, with and without extensions
Upvotes: 4
Views: 53