tailwindcss: Nuxt 3 issue "Cannot read property 'resolveAlias' of undefined"
Version
@nuxtjs/tailwindcss: 4.2.1 nuxt: nuxt3@3.0.0-27234271.da7ff44
Reproduction Link
https://codesandbox.io/s/hungry-diffie-k8odx
Steps to reproduce
none
What is Expected?
no error to be produced
What is actually happening?
error is produced:
ERROR Cannot restart nuxt: Cannot read property 'resolveAlias' of undefined
at Object.tailwindCSSModule (node_modules/@nuxtjs/tailwindcss/dist/index.js:51:36)
at installModule (node_modules/@nuxt/kit/dist/index.mjs:1196:17)
at initNuxt (node_modules/nuxt3/dist/index.mjs:817:11)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async load (node_modules/nuxi/dist/chunks/dev.mjs:6762:9)
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 53
- Comments: 29 (3 by maintainers)
Thank you @productfrontenddeveloper
What got it working for my repo was:
I’m still learning
nuxtbut thatbuilddefinition seemed to get things runningI think this package is no longer needed, because nuxt now uses webpack 5 and already supports tailwindcss. Install tailwind as next.js:
npm install -D tailwindcss@latest postcss@latest autoprefixer@latestnpx tailwindcss init -pOhh it is, better approach I believe
An example of nuxt3 with tailwind: nuxt3-tailwind
Thanks a lot to @JDIZM
Thanks for the updates! The module gives the possibility to other module authors to configure the tailwind config but we may see in the future if we have to deprecate this module.
We recommend to use the
app.vueto have HMR instead of using thenuxt.configfile (thecssprop should be kept only for module authors)For me worked really simple with following Tailwind CSS Docs and @neilmispelaar recommendation.
nuxt.config.ts
This worked amazingly.
Had to change
css: ['tailwindcss/tailwind.css'],tocss: ['@/assets/css/tailwind.css']for better flexibility over my tailwind.css.Expecting an update to the tailwind docs around this.
After upgrading to the latest nuxt3 version, tailwind doesn’t work for me anymore. I follow the instructions and yesterday it was working as expected. Haven’t change anyhting, but today it doesn’t work, without changing anything. It also doesn’t show any erros.
5.0.0-alpha released with Nuxt 3 and Tailwindcss 3 support. Release notes https://github.com/nuxt-community/tailwindcss-module/releases/tag/v5.0.0-0.
none of these works with latest nuxt3 version:
everything results in an unparsed css:
Awesome, thanks! Makes me wonder now what’s the use for the
@nuxt/tailwindcssmodule? Consider adding npm i tailwind-config-viewer -Dto your project and change scripts in package.json toI tried this out & it worked for now.
In the nuxt config file add the following.
Inside the tailwind config.js add the following
@MrParano1d check working repo https://github.com/productfrontenddeveloper/nuxt3-app
@productdevbook Good point.
In my case
tailwindcss/tailwind.cssnever changes. Onlytailwind.config.jsandpostcss.config.jscan be changed. And we can achieve a kind of Server HMR by addingwatchto config. Useapp.vueonly when have your custom CSS file likeassets/css/tailwind.cssnux.config.ts
@iamandrewluca
Atinux say
We recommend to use the app.vue to have HMR instead of using the nuxt.config file (the css prop should be kept only for module authors)
Please check repo setup 😃 -> https://github.com/productfrontenddeveloper/nuxt3-app
@productfrontenddeveloper you can remove the
postcss.configfile.This is great, updating the module should be straightforward 😀