简体   繁体   中英

Nuxt 3 extending a project causes an error

Whenever I try to extend another Nuxt 3 project using:

export default defineNuxtConfig({   // this is inside the nuxt.config.ts in `main-project`
    extends: [
        '../test-extend'
    ]
})

I get an error saying that a module could not be found (for example: Cannot start nuxt: Cannot find module '@vueuse/nuxt')

My directory structure looks like this:

📂 
├── 📂 test-extend/
└── 📂 main-project/

Am I doing something wrong? I tried putting the test-extend project inside the main-project to see whether the path wasn't a problem but that didn't help either...

After some experimenting I found out that the error disappears when I add the dependencies of the parent layer ( test-extend ) to the main-project . This might seem like a super obvious solution in retrospect, however, I think it is a bug because the documentation mentions "Create Nuxt module presets" as one of the features of Nuxt Layers & I don't think this is really "creating a module preset" if I have to remember what dependencies are installed in the layer & then add them manually to the new project anyway.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM