-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Cannot use aliases inside serverMiddleware #4580
Comments
Upgraded today to 2.3.4, aliases not working for me, too |
in the server export it like so
am on v-2.3.4. then you can go to |
@alexdohmen Do you mean aliases in server middleware, right? Because I experienced this issue in server middleware only. Just for clarifying. |
@devyaz Sorry, but I've explain it..please read it carefully..
Basically, I know it will solves the problem. But It didn't make sense, since I use aliases too inside |
oh ok! but i think they only work inside of Nuxt because Express will not use the alias and its included(imported) in express so on the Express viewpoint it has to be relative or use |
@devyaz That's the problem. So, we can't use aliases inside server middleware. Nuxt has define aliases, so it must be available in all context. When using my own server implementation (not server middleware), I just need to use Backpack and added aliases to it's config, to make node recognize my aliases. |
As this never has been implemented (AFAIK) this is a feature request and no bug report. We don't touch |
I've been having this issue as well. Has there been progress on this or do we continue to require modules relatively? |
Running into the same issue here. It's no problem to modify a few of the initial imports to use relative paths, but it's the deep dependencies (things in Does anyone have experience applying Webpack aliases outside of the primary client/server bundles? I'm really stumped, and it seems like a silly thing, but the alternative is crazy module pathing like |
Same issue. It forces not to use aliases in all shared code. I think this |
@Atinux @manniL @pi0 it will help a lot if you implement it, guys. Maybe someone knows some alternatives? I tried module-alias but I failed to get this to work with the Nuxt. |
It has been a while since I'm writing Nuxt app. Ok, it's good to see if this is not an issue, but feature request. So, is it possible to make @iliyaZelenko I've mention it before, you can using Backpack. After that, you could make the aliases work in server side. |
Some quick notes:
|
Not sure this is related to the same issue, but @pi0 did you notice the same behavior on the nuxt custom modules? I'm using aliases like this:
It's working quite well on all the application but on Node obviously. So I added the alises on node as well. It almost worked since a custom module with nothing in it (but using a relative import
It's happening right after I get the dev' message "ℹ Initial build may take a while", so I guess nuxt is loaded. Either way, node or nuxt does not seem to resolve my alias. Any idea why? Thanks! |
I hope Nuxt team can implement |
Nuxt version: 2.13+ package.json:
I used this configuration for the ability to use |
Remove TODO as this change would introduce this issue: nuxt/nuxt#4580
This comment has been minimized.
This comment has been minimized.
I personally solved it by installing |
This is now implemented in Nuxt 3. |
Version
v2.3.4
Reproduction link
https://codesandbox.io/s/vvm38xp7ny
Steps to reproduce
Creating a project with
create-nuxt-app
Create the serverMiddleware:
Add some file, something like
util.js
:Import the
common/util.js
inapi/index.js
Add the serverMiddleware to the
nuxt.config.js
:What is expected ?
The aliases should be available inside serverMiddleware.
What is actually happening?
Additional comments?
Without aliases, we need to replace all imports that uses aliases, to relative path, in this case in
api/index.js
(server middleware).But, what about if we use another import aliases inside
common/util.js
?The text was updated successfully, but these errors were encountered: