N
Nuxt3mo ago
CG Seb

NuxtUI: Impossible to install

Hi, I was previously using Tailwind and I just found out about NuxtUI. I removed my @nuxtjs/tailwindcss and followed the official documentation for NuxtUI => https://ui.nuxt.com/getting-started/installation/nuxt I did all that is mentioned, but I get this error
ERROR Pre-transform error: Can't resolve 'tailwindcss' in '/app/app/assets/css'
Plugin: @tailwindcss/vite:generate:serve
File: /app/app/assets/css/main.css


ERROR Pre-transform error: Invalid declaration: ``
Plugin: @tailwindcss/vite:generate:serve
File: /app/app/app.vue?vue&type=style&index=0&lang.css
ERROR Pre-transform error: Can't resolve 'tailwindcss' in '/app/app/assets/css'
Plugin: @tailwindcss/vite:generate:serve
File: /app/app/assets/css/main.css


ERROR Pre-transform error: Invalid declaration: ``
Plugin: @tailwindcss/vite:generate:serve
File: /app/app/app.vue?vue&type=style&index=0&lang.css
Here is my nuxt.config.ts
modules: [
'@nuxt/ui',
'@nuxtjs/google-fonts',
'@nuxt/icon',
'@nuxt/image',
'@pinia/nuxt',
'pinia-plugin-persistedstate/nuxt',
],
css: ['~/assets/css/main.css'],
modules: [
'@nuxt/ui',
'@nuxtjs/google-fonts',
'@nuxt/icon',
'@nuxt/image',
'@pinia/nuxt',
'pinia-plugin-persistedstate/nuxt',
],
css: ['~/assets/css/main.css'],
My /app/assets/css/main.css
@import "tailwindcss";
@import "@nuxt/ui";
@import "tailwindcss";
@import "@nuxt/ui";
I've been trying to make it work for hours, maybe someone has an idea of what I'm doing wrong 🙏
Nuxt UI
Installation - Nuxt UI
Learn how to install and configure Nuxt UI in your Nuxt application.
12 Replies
kapa.ai
kapa.ai3mo ago
Hi @CG Seb. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The error message you’re seeing:
ERROR Pre-transform error: Can't resolve 'tailwindcss' in '/app/app/assets/css'
Plugin: @tailwindcss/vite:generate:serve
File: /app/app/assets/css/main.css
ERROR Pre-transform error: Can't resolve 'tailwindcss' in '/app/app/assets/css'
Plugin: @tailwindcss/vite:generate:serve
File: /app/app/assets/css/main.css
indicates that the Tailwind CSS package is not installed in your project. Even though Nuxt UI handles much of the Tailwind configuration for you, you still need to have the tailwindcss package installed as a dependency in your project. This is also mentioned in the official Nuxt UI documentation:
If you're using pnpm, ensure that you either set shamefully-hoist=true in your .npmrc file or install tailwindcss in your project's root directory.
Nuxt UI Installation Guide How to fix: 1. Install Tailwind CSS
Run the following command in your project root:
npm install tailwindcss

npm install tailwindcss

or, if you use yarn:
yarn add tailwindcss

yarn add tailwindcss

or, if you use pnpm:
pnpm add tailwindcss

pnpm add tailwindcss

2. Verify your main.css
Your /app/assets/css/main.css should look like:
@import "tailwindcss";
@import "@nuxt/ui";

@import "tailwindcss";
@import "@nuxt/ui";

This is correct as per the documentation. 3. No need for @nuxtjs/tailwindcss
You do not need the @nuxtjs/tailwindcss module when using Nuxt UI, as Nuxt UI manages Tailwind for you. 4. Check your nuxt.config.ts
Your configuration looks correct:
export default defineNuxtConfig({
modules: [
'@nuxt/ui',
// ...other modules
],
css: ['~/assets/css/main.css'],
})

export default defineNuxtConfig({
modules: [
'@nuxt/ui',
// ...other modules
],
css: ['~/assets/css/main.css'],
})

Summary:
You just need to install the tailwindcss package in your project. Once installed, the error should be resolved and Nuxt UI will work as expected with your current setup. If you continue to have issues, make sure there are no typos in your file paths and that your dependency installation completed successfully.
Official Nuxt UI Installation Docs ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai3mo ago
<@182470797850312704> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
CG Seb
CG SebOP3mo ago
@kapa.ai It fixed the first error but I still have this one
ERROR Pre-transform error: Invalid declaration: ``
Plugin: @tailwindcss/vite:generate:serve
File: /app/app/app.vue?vue&type=style&index=0&lang.css
ERROR Pre-transform error: Invalid declaration: ``
Plugin: @tailwindcss/vite:generate:serve
File: /app/app/app.vue?vue&type=style&index=0&lang.css
kapa.ai
kapa.ai3mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- The error:
ERROR Pre-transform error: Invalid declaration: ``
Plugin: @tailwindcss/vite:generate:serve
File: /app/app/app.vue?vue&type=style&index=0&lang.css
ERROR Pre-transform error: Invalid declaration: ``
Plugin: @tailwindcss/vite:generate:serve
File: /app/app/app.vue?vue&type=style&index=0&lang.css
suggests that there is an invalid or empty CSS declaration in your <style> block within app.vue. This is not directly related to Nuxt UI, but rather to how CSS is written in your Vue component. What to check: - Open your app.vue file and look for any <style> blocks. - Make sure there are no empty CSS rules or invalid declarations, such as:
.some-class {
/* nothing here or just a stray backtick or invalid syntax */
}

.some-class {
/* nothing here or just a stray backtick or invalid syntax */
}

- Remove any empty or malformed CSS blocks. Example of a valid style block:
<template>
<UApp>
<NuxtPage />
</UApp>
</template>

<style>
/* Only add valid CSS here, or remove the block if not needed */
</style>
<template>
<UApp>
<NuxtPage />
</UApp>
</template>

<style>
/* Only add valid CSS here, or remove the block if not needed */
</style>
If you have an empty <style> block, you can safely remove it. The knowledge sources do not explicitly mention this error, but based on the error message and standard Vue/Nuxt usage, this is the most likely cause. If the problem persists after cleaning up your CSS, please provide the contents of your app.vue file for further assistance. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai3mo ago
<@182470797850312704> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
CG Seb
CG SebOP3mo ago
@kapa.ai It looks like this is wrong
html, body {
background-color: #1F1F1F;
margin: 0;
padding: 0;
}
html, body {
background-color: #1F1F1F;
margin: 0;
padding: 0;
}
When I remove it it works
kapa.ai
kapa.ai3mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- You're correct—removing the following CSS block resolves the error:
html, body {
background-color: #1F1F1F;
margin: 0;
padding: 0;
}
html, body {
background-color: #1F1F1F;
margin: 0;
padding: 0;
}
The knowledge sources do not explicitly mention that this specific CSS would cause a "Pre-transform error: Invalid declaration," but they do show that Nuxt UI and Tailwind CSS expect you to use their utility classes and theming system for styling, rather than direct CSS overrides in your global styles. Nuxt UI applies background and text color to the <body> using Tailwind's utility classes and CSS variables, for example:
body {
@apply antialiased text-default bg-default scheme-light dark:scheme-dark;
}
body {
@apply antialiased text-default bg-default scheme-light dark:scheme-dark;
}
This approach ensures compatibility with the design system and avoids conflicts or parsing errors that might arise from custom CSS, especially if there are syntax issues or if the CSS is not processed as expected by Tailwind or Vite plugins Nuxt UI Theme - Neutral. If you need to customize the background color, it's recommended to do so using the Nuxt UI theming system or Tailwind utility classes, rather than direct CSS in your global stylesheet. This will help prevent similar errors and ensure your styles integrate smoothly with Nuxt UI. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai3mo ago
<@182470797850312704> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
HugoRCD
HugoRCD3mo ago
That can't cause this error! Could you send your package.json and delete your node_modules and maybe lockfile to make sure the shamefully-hoist worked?
CG Seb
CG SebOP3mo ago
Well I don't have the error anymore and my page is showing, but I my custom colors and classes I have in my tailwind.config.js are not working. I tried removing node_modules mutiple times and it didn't work. Here is my package.json
{
"name": "app-front",
"version": "0.1.0",
"private": true,
"type": "module",
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare"
},
"dependencies": {
"@codemirror/lang-css": "^6.3.1",
"@codemirror/lang-html": "^6.4.9",
"@codemirror/language": "^6.11.1",
"@codemirror/state": "^6.5.2",
"@codemirror/theme-one-dark": "^6.1.2",
"@codemirror/view": "^6.37.2",
"@headlessui/vue": "^1.7.23",
"@heroicons/vue": "^2.2.0",
"@iconify-json/mdi": "^1.2.3",
"@iconify/vue": "^5.0.0",
"@nuxt/icon": "^1.12.0",
"@nuxt/image": "^1.10.0",
"@nuxt/ui": "^3.1.3",
"@nuxtjs/google-fonts": "^3.2.0",
"@pinia/nuxt": "^0.11.0",
"@tailwindcss/container-queries": "^0.1.1",
"@tailwindcss/forms": "^0.5.10",
"@vueup/vue-quill": "^1.2.0",
"node-fetch": "^3.3.2",
"nuxt": "^3.17.5",
"pinia": "^3.0.2",
"pinia-plugin-persistedstate": "^4.3.0",
"postcss": "^8.5.3",
"postcss-prefix-selector": "^2.1.1",
"tailwindcss": "^4.1.10",
"typescript": "^5.8.3",
"uuid": "^11.1.0",
"vee-validate": "^4.15.0",
"vue": "^3.5.13",
"vue-codemirror6": "^1.3.18",
"vue-router": "^4.5.1",
"vuedraggable": "^4.1.0",
"yup": "^1.6.1"
}
}
{
"name": "app-front",
"version": "0.1.0",
"private": true,
"type": "module",
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare"
},
"dependencies": {
"@codemirror/lang-css": "^6.3.1",
"@codemirror/lang-html": "^6.4.9",
"@codemirror/language": "^6.11.1",
"@codemirror/state": "^6.5.2",
"@codemirror/theme-one-dark": "^6.1.2",
"@codemirror/view": "^6.37.2",
"@headlessui/vue": "^1.7.23",
"@heroicons/vue": "^2.2.0",
"@iconify-json/mdi": "^1.2.3",
"@iconify/vue": "^5.0.0",
"@nuxt/icon": "^1.12.0",
"@nuxt/image": "^1.10.0",
"@nuxt/ui": "^3.1.3",
"@nuxtjs/google-fonts": "^3.2.0",
"@pinia/nuxt": "^0.11.0",
"@tailwindcss/container-queries": "^0.1.1",
"@tailwindcss/forms": "^0.5.10",
"@vueup/vue-quill": "^1.2.0",
"node-fetch": "^3.3.2",
"nuxt": "^3.17.5",
"pinia": "^3.0.2",
"pinia-plugin-persistedstate": "^4.3.0",
"postcss": "^8.5.3",
"postcss-prefix-selector": "^2.1.1",
"tailwindcss": "^4.1.10",
"typescript": "^5.8.3",
"uuid": "^11.1.0",
"vee-validate": "^4.15.0",
"vue": "^3.5.13",
"vue-codemirror6": "^1.3.18",
"vue-router": "^4.5.1",
"vuedraggable": "^4.1.0",
"yup": "^1.6.1"
}
}
Thanks for the response 🙂
HugoRCD
HugoRCD3mo ago
This is because NuxtUI now uses Tailwind v4 and the configuration file is no longer used by tailwind by default https://tailwindcss.com/docs/functions-and-directives#config-directive
Functions and directives - Core concepts
A reference for the custom functions and directives Tailwind exposes to your CSS.
CG Seb
CG SebOP3mo ago
Great I will transform my config then thanks!

Did you find this page helpful?