#Cannot read .vue files of external packages
3 messages · Page 1 of 1 (latest)
It looks like Vite/Nuxt isn’t transforming .vue files when they come from an external package path (installed via file:), so Node tries to load them directly and errors on the unknown “.vue” extension. In Nuxt, third‑party SFCs should be registered through Nuxt’s component system so they’re compiled by Vite.
- Use a Nuxt module and register the component with addComponent so Nuxt auto‑imports and compiles it (avoid importing the .vue file directly at runtime). Example from the docs: addComponent({ name: 'MyAutoImportedComponent', filePath: 'my-npm-package' }) (you can target your package entry or a compiled export rather than a raw .vue path) (addComponent).
- If you maintain the external package, consider exposing components via a Nuxt module that calls addComponentsDir so consumers can load SFCs from node_modules while ensuring Nuxt compiles them (Library Authors).
- Alternatively, in the consuming app register components from an npm package via a local module using addComponent (same as above) (Custom directories → npm Packages).