nuxt / components

Scan and auto import components for Nuxt.js 2.13+

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Obscure Webpack Import Error

MentalGear opened this issue · comments

Just wanted to share this somewhat obscure error message and how I solved it, in case others come across it.

ERROR Failed to compile with 1 errors
ERROR in ./.nuxt/components/plugin.js
Syntax Error: Unexpected token (10:2)

10 | : () => import('../../components/index.vue' /* webpackChunkName: "components/" */).then(c => wrapFunctional(c.default || c))
| ^
11 | }
12 |
13 | for (const name in components) {

After a few hours, I realized that I renamed a file to index.vue in the /components folder without noticing it, which apparently crashes nuxt with this error. (Maybe something could also be done to make that error clearer.)

Takeaway:

Don't put a index.vue file into components (or probably any other place but /pages folder).