Description
Before using nuxt ui, I briefly skimmed through the repository and found an already closed issue: 3018
The error and solution mentioned in this issue (the v2 documentation indeed did not mention the solution) can actually be resolved by adding tailwindcss@next to the peerDependencies section in the package.json file.
This is because when nuxi module add installs a module, it not only installs the module itself but also scans the module package's peerDependencies.
For example, when using nuxi module add pinia, since @pinia/nuxt has pinia listed in its peerDependencies in the package.json, both @pinia/nuxt and pinia will be automatically installed during the module installation.
If there are dependencies in peerDependencies that you do not want nuxi module to install automatically, you can use peerDependenciesMeta to ignore them, for example:
"peerDependenciesMeta": {
"pinia": {
"optional": true
}
},
Therefore, Nuxt UI can specify tailwindcss@next in the peerDependencies of package.json, ensuring Tailwind CSS is automatically installed when the Nuxt UI module is installed.
This solution applies to both v3 and v2.
PS: I noticed typescript in the peerDependencies of the v3 package.json. Is this a necessary dependency similar to tailwindcss? If not, after adding tailwindcss, perhaps peerDependenciesMeta could be used to ignore it.
Description
Before using
nuxt ui, I briefly skimmed through the repository and found an already closed issue: 3018The error and solution mentioned in this issue (the v2 documentation indeed did not mention the solution) can actually be resolved by adding
tailwindcss@nextto thepeerDependenciessection in thepackage.jsonfile.This is because when nuxi module add installs a module, it not only installs the module itself but also scans the module package's
peerDependencies.For example, when using
nuxi module add pinia, since@pinia/nuxthaspinialisted in itspeerDependenciesin the package.json, both@pinia/nuxtandpiniawill be automatically installed during the module installation.If there are dependencies in
peerDependenciesthat you do not wantnuxi moduleto install automatically, you can usepeerDependenciesMetato ignore them, for example:Therefore, Nuxt UI can specify
tailwindcss@nextin thepeerDependenciesofpackage.json, ensuring Tailwind CSS is automatically installed when the Nuxt UI module is installed.This solution applies to both v3 and v2.