-
-
Notifications
You must be signed in to change notification settings - Fork 168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
could not resolve import when module isEnabled = false #454
Comments
any solution? |
Make sure that in the application that you are referencing that imports #auth has the module for '@sidebase/nuxt-auth', imported in the nuxt.config.ts file. I'm not totally sure how your mutli site is wired, but each nuxt instance needs the import to build out the type stubs/ definitions when the nuxt / vite lifecycle hooks are called. Without this module running, it will not build out your types and ts will show an error. |
I would then recommend you rename the above file to something else ie authApi.ts and then name a new file what it is currently, the import the old file based on if the auth is enabled or disabled. As of right now you are trying to import a reference when it's prescribing module import isn't built. [...].ts' |
In my opinion it would make sense to still provide the virtual module (#auth) and all of its exports even if the auth package is disabled and "just" disable the whole authorization logic inside the package. |
@agracia-foticos I understand your problem, however I see multiple issues with exposing all the exports.
For 1. I would recommend you look at my answer here on how to properly mock an authentication request (without disabling the module). If you have any other use cases for
please let me know and we can futhur discuss this matter! |
Related to #596 |
Environment
Linux
v18.16.0
3.5.3
2.4.1
[email protected]
vite
-
-
-
Reproduction
We are using the same code, for multi-site APP... same sites has login and others sites hasnt login.
We have a wrapper to use useAuth, but we have a problem with
src/server/routes/api/auth/[...].ts file...
we have the module disabled but when in auth file try to import import { NuxtAuthHandler } from '#auth' throws an error
(node-resolve plugin) Could not resolve import "#auth" in /home/var/www/src/server/routes/api/auth/[...].ts using imports defined in /home/var/www/package.json. (node-resolve plugin) Could not resolve import "#auth" in /home/var/www/src/server/routes/api/auth/[...].ts using imports defined in /home/var/www/package.json. "#auth" is imported by "src/server/routes/api/auth/[...].ts", but could not be resolved – treating it as an external dependency.
If we use visual studio debugger, we cant start the app, only can with npx nuxi build and node start
Describe the bug
We are using the same code, for multi-site APP... same sites has login and others sites hasnt login.
We have a wrapper to use useAuth, but we have a problem with
src/server/routes/api/auth/[...].ts file...
we have the module disabled but when in auth file try to import import { NuxtAuthHandler } from '#auth' throws an error
(node-resolve plugin) Could not resolve import "#auth" in /home/var/www/src/server/routes/api/auth/[...].ts using imports defined in /home/var/www/package.json. (node-resolve plugin) Could not resolve import "#auth" in /home/var/www/src/server/routes/api/auth/[...].ts using imports defined in /home/var/www/package.json. "#auth" is imported by "src/server/routes/api/auth/[...].ts", but could not be resolved – treating it as an external dependency.
If we use visual studio debugger, we cant start the app, only can with npx nuxi build and node start
Additional context
No response
Logs
No response
The text was updated successfully, but these errors were encountered: