question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:

  1. Clone repository ‘https://github.com/m7rlin/nuxt-auto-import-components
  2. Run ‘npm run generate’
  3. Then run ‘npm run start’
  4. 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: image

How it should look like: image

Additional context When I import the components the normal way, they are visible on production.

image

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:closed
  • Created 2 years ago
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
pi0commented, Aug 16, 2021

The regression is fixed in components@2.2.1. Just remove yarn.lock/package.lock.json and reinstall dependencies.

1reaction
richardeschlosscommented, Aug 27, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found