Module resolution error for '@' alias when importing Vue components
0 reputation · 08 Dec 2022, 17:41 UTC
The goal is to understand why a Nuxt 3 deployment build log shows a module resolution error stating that the alias '@' cannot be resolved for a Vue component import during the build step.
This failure appears to depend on whether the alias is defined in nuxt.config.ts, and it may differ between Nuxt 2 (webpack) and Nuxt 3 (Vite) builds. It remains uncertain whether the alias must be declared explicitly or can be inferred from tsconfig path mappings, and whether the error is triggered only for absolute imports using '@' or also for relative imports.
- What is the correct way to define the '@' alias in nuxt.config.ts for a Vite‑based Nuxt 3 project?
- Does omitting the alias cause the build to fail only for absolute imports that use '@', or does it also affect relative imports?
- How does the module resolver behave when the alias is missing in a Nuxt 2 (webpack) project compared to a Nuxt 3 (Vite) project?