No auto import of components after 'nuxt generate'
See original GitHub issue``Describe the bug When use ‘components: true’ and then import a component on my page it is working just fine on ‘dev’ but after running ‘generate’ command and starting ‘start’ the web server I don’t see any of my components that should be auto imported.
To Reproduce Steps to reproduce the behavior:
- Clone repository ‘https://github.com/m7rlin/nuxt-auto-import-components’
- Run ‘npm run generate’
- Then run ‘npm run start’
- Open the server on ‘http://localhost:3000’ and see that the ‘@/components/webblocks/Cards.vue’ component is not there
Expected behavior Auto imported components should be visible on production.
Screenshots
On production now:
How it should look like:
Additional context When I import the components the normal way, they are visible on production.
EDIT: If I do this on package.json (npm)
...
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate",
"lint:js": "eslint --ext \".js,.vue\" --ignore-path .gitignore .",
"lint": "npm run lint:js",
"preinstall": "npx npm-force-resolutions"
},
...
},
"resolutions": {
"@nuxt/components": "2.1.8"
}
...
It seems working just fine. EDIT: I found that downgrading “nuxt components” to v2.1.8 fix the problem.
“@nuxt/components”: “2.1.8”
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (2 by maintainers)
Top Results From Across the Web
The components Property - Nuxt
It will automatically import the components only if used and also support HMR when updating your components in node_modules/awesome-ui/components/ .
Read more >Nuxt not automatically importing components from nested ...
If i don't use the directory name as part of the filename, dynamic imports are not working for components in nested directories. Is...
Read more >Importing and Using Components in Nuxt 3 - Server Side Up
When migrating from Nuxt 2 to Nuxt 3, components are now imported and used through auto imports instead of explicit importing.
Read more >Nuxt.js: Auto-imported components are highlighted as ...
This happens for every component which is imported only by auto-import, if I have at least one manual importing of some component -...
Read more >Auto imports · Nuxt Concepts
In case you want to disable auto-imports, you can set imports.autoImport to false . nuxt.config.ts export default defineNuxtConfig({ ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The regression is fixed in components@2.2.1. Just remove
yarn.lock
/package.lock.json
and reinstall dependencies.This is just a guess, but it seems like the v-lazy-image takes advantage of npm (or pnpm?) workspaces, so that importing from ‘@hzzt/v-lazy-image’ would resolve to the ESM vue component index.js instead of a commonjs file.