N
Nuxt2y ago
oemer

Do I need to install dependencies of Layers I am extending in a monorepo?

If I don't install the dependencies of Layer I am extending, I get errors that modules can be found. I've tried several things. But the solutions don't work for all dependencies and are inconsistent... Here is an example: /base-layer nuxt.config.ts
import { createResolver } from "@nuxt/kit"
import vuetify from "vite-plugin-vuetify"
const { resolve } = createResolver(import.meta.url)

export default defineNuxtConfig({
css: [resolve("./node_modules/vuetify/lib/styles/main.sass")], // works
modules: [resolve("./node_modules/@pinia/nuxt/dist/module.mjs")], // works
alias: {
pinia: resolve("./node_modules/pinia"), // works
vuetify: resolve("./node_modules/vuetify") // still doesn't work: Cannot start nuxt: Cannot find module 'vuetify/package.json' in /other-layer when runing `yarn dev`
}
})
import { createResolver } from "@nuxt/kit"
import vuetify from "vite-plugin-vuetify"
const { resolve } = createResolver(import.meta.url)

export default defineNuxtConfig({
css: [resolve("./node_modules/vuetify/lib/styles/main.sass")], // works
modules: [resolve("./node_modules/@pinia/nuxt/dist/module.mjs")], // works
alias: {
pinia: resolve("./node_modules/pinia"), // works
vuetify: resolve("./node_modules/vuetify") // still doesn't work: Cannot start nuxt: Cannot find module 'vuetify/package.json' in /other-layer when runing `yarn dev`
}
})
package.json
"dependencies": {
"@pinia/nuxt": "^0.4.9",
"pinia": "^2.0.35",
"sass": "^1.62.1",
"vite-plugin-vuetify": "^1.0.2",
"vuetify": "^3.1.16"
}
"dependencies": {
"@pinia/nuxt": "^0.4.9",
"pinia": "^2.0.35",
"sass": "^1.62.1",
"vite-plugin-vuetify": "^1.0.2",
"vuetify": "^3.1.16"
}
/other-layer nuxt.config.ts
export default defineNuxtConfig({
extends: ["../base-layer"]
})
export default defineNuxtConfig({
extends: ["../base-layer"]
})
package.json
"dependencies": {}
"dependencies": {}
`
4 Replies
warflash
warflash2y ago
We need to install manually install the packages in each project yeah, but not using a monorepo over here. https://github.com/unjs/c12/issues/51. Regarding the vuetify error I assume the vuetify package.json just doesnt sit in the root of the module
oemer
oemerOP2y ago
@warflash I saw this issues and also others. They always mention remote sources as the problem, but do not mention local dependenices (monorepos). That's why I was expecting it to work for me, but it seems like it doesn't. It's really annoying if you have 5 layers and have to sync all dependencies manually.
No description
warflash
warflash2y ago
Yeah it's a pain keeping them all in sync and having so much duplicate config stuff But since pinia is resolving for you I'm pretty sure the error comes from the vuetify package json path and not general dependency installs missing
oemer
oemerOP2y ago
Well, for me "working" would mean: You don't have to do do any aliasing of the packages. But here I have to do the aliasing manually. Meh. I hoped Layers would help me get cleaner code with less complexity, but here we also have to add some complexity to even use it properly.
Want results from more Discord servers?
Add your server