NuxtN
Nuxt‱2mo ago‱
19 replies
Dustin

import defineNitroPlugin or not? Import aliases not working in /server/plugins/*.ts

Hi, I created a new Project today on the newest version 4.2.1 and for some reason I dont get type hints for defineNitroPlugin anymore. Also, I cannot import from e.g. "~~/server/utils/auth".

This works in server utils and API routes, but for some reason, in plugins, it does not.

If I run the dev server everything works. I am using this plugin to create a better-auth superuser (I just need 1 user), is there another way I can / should do this?

In the docs it tells me: "It is necessary to explicitly import defineNitroPlugin from nitropack/runtime within your plugin file.", but I have another app in which the type completion works, also on the newest nuxt version.

I tried:
- deleting node_modules and .nuxt folders and recreating them multiple times.
- restarting dev server


If I need to explicitly import it, that is fine by me, but why does my other app work? 😄
Was this page helpful?