Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New module v6.13 isn't working on freshly started project #939

Closed
laspinacristian opened this issue Jan 13, 2025 · 14 comments
Closed

New module v6.13 isn't working on freshly started project #939

laspinacristian opened this issue Jan 13, 2025 · 14 comments
Labels
bug Something isn't working

Comments

@laspinacristian
Copy link

Environment

------------------------------
- Operating System: Linux
- Node Version:     v22.12.0
- Nuxt Version:     3.15.1
- CLI Version:      3.20.0
- Nitro Version:    2.10.4
- Package Manager:  [email protected]
- Builder:          -
- User Config:      compatibilityDate, devtools, modules
- Runtime Modules:  @nuxtjs/[email protected]
- Build Modules:    -
------------------------------

Reproduction

Create a new nuxt project with nuxi 3.20.0
npx nuxi@latest init my-nuxt-project

Install Nuxt tailwindcss module
npx nuxi module add tailwindcss

Run dev and it will fail
npm run dev

With the following error:

Describe the bug

Nuxt 3.15.1 with Nitro 2.10.4                                                                                                                                                                       nuxi 17:39:55
                                                                                                                                                                                                         17:39:55
  ➜ Local:    http://localhost:3000/
  ➜ Network:  use --host to expose

ℹ Using default Tailwind CSS file                                                                                                                                                      nuxt:tailwindcss 17:39:57
  ➜ DevTools: press Shift + Alt + D in the browser (v1.7.0)                                                                                                                                              17:39:58

✔ Vite client built in 44ms                                                                                                                                                                             17:39:59
✔ Vite server built in 547ms                                                                                                                                                                            17:40:00

 ERROR  Pre-transform error: [postcss] Cannot find module './../../tailwind.config'                                                                                                                      17:40:00
Require stack:
- /home/cristian/workspace/nuxt-horsing/.nuxt/tailwind/postcss.mjs
  Plugin: vite:css
  File: /home/cristian/workspace/nuxt-horsing/node_modules/tailwindcss/tailwind.css:undefined:NaN


 ERROR  Pre-transform error: [postcss] Cannot find module './../../tailwind.config'                                                                                                                      17:40:00
Require stack:
- /home/cristian/workspace/nuxt-horsing/.nuxt/tailwind/postcss.mjs
  Plugin: vite:css
  File: /home/cristian/workspace/nuxt-horsing/node_modules/vite-plugin-vue-inspector/src/Overlay.vue?vue&type=style&index=0&scoped=31d1379f&lang.css:undefined:NaN

Additional context

No response

Logs

@laspinacristian laspinacristian added the bug Something isn't working label Jan 13, 2025
@xusimr97
Copy link

I had the same problem with layers. I have forced the version to "@nuxtjs/tailwindcss": "^6.12.1" until they
fix it

@dargmuesli
Copy link
Contributor

6.13.0 expects a tailwind.config.(js|ts) to exist, while previously a default configuration was loaded when there was no such file, it appears.

Previous .nuxt/tailwind.config.cjs:

// generated by the @nuxtjs/tailwindcss <project-path>node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/@nuxtjs/tailwindcss/dist/runtime/merger.js");

const inlineConfig = {"content":[],"theme":{"extend":{}},"plugins":[]};

const config = [
require("<package-path>/tailwind.config.ts")
].reduce((prev, curr) => configMerger(curr, prev), configMerger(inlineConfig, { content: { files: [...] } }));

module.exports = config

New .nuxt/tailwind/postcss.mjs:

// generated by the @nuxtjs/tailwindcss <https://github.com/nuxt-modules/tailwindcss> module at 1/14/2025, 12:47:04 AM
import configMerger from "@nuxtjs/tailwindcss/merger";

import cfg2 from "./../../tailwind.config";
import cfg4 from "<package-path>/tailwind.config.ts";
const config = [
{"content":{"files":[...]}},
{},
cfg2,
{...},
cfg4
].reduce((acc, curr) => configMerger(acc, curr), {});

const resolvedConfig = config;

export default resolvedConfig;

... where import cfg2 from "./../../tailwind.config"; should not be there if the project has no such file, I'd say.

@MarioPeperoni
Copy link

I fixed the error by manually initialising tailwind config using the npx tailwindcss init command. It places tailwind.config in root.

@ineshbose
Copy link
Collaborator

Apologies about this bug! Seems like a check is missing here: https://github.com/nuxt-modules/tailwindcss/blob/main/src/internal-context/load.ts#L110 (I thought that c12 returned undefined for non-resolved paths, but that's not the case - https://github.com/unjs/c12/blob/main/src/loader.ts#L376)

Will release a fix in an hour.

@ineshbose
Copy link
Collaborator

v6.13.1 released. Let me know if it persists.

@dargmuesli
Copy link
Contributor

Looks good at first glance, thanks! ❤️

@Luca-Sett
Copy link

Luca-Sett commented Jan 15, 2025

Hi @ineshbose, I have v6.13.1 of the @nuxtjs/tailwindcss module installed in a Nuxt Layer. The module works correctly in the layer when testing with the .playground folder, but I can't get a separate Nuxt project which extends the layer to work:

 ERROR  Pre-transform error: [postcss] Cannot find module '@nuxtjs/tailwindcss/merger'                                                                            15:21:11  
Require stack:
- D:\dominate-kitchen\.nuxt\tailwind\postcss.mjs
  Plugin: vite:css
  File: D:/dominate-kitchen/node_modules/vite-plugin-vue-inspector/src/Overlay.vue?vue&type=style&index=0&scoped=31d1379f&lang.css:undefined:NaN

@mrleblanc101
Copy link

mrleblanc101 commented Jan 15, 2025

I still have error inside my app that extend a Layer.

Image
ERROR  [uncaughtException] Cannot find module '/Users/sleblanc/www/app_name/.nuxt/tailwind.config.cjs'   11:18:15 AM
Require stack:
- /Users/sleblanc/www/app_name/node_modules/tailwindcss/lib/lib/load-config.js
Occurred while linting /Users/sleblanc/www/app_name/app/app.config.ts:1
Rule: "prettier/prettier"

    Require stack:
    - node_modules/tailwindcss/lib/lib/load-config.js
    at Function._resolveFilename (node:internal/modules/cjs/loader:1225:15)
    at Function.resolve (node:internal/modules/helpers:190:19)
    at _resolve (node_modules/tailwindcss/node_modules/jiti/dist/jiti.js:1:246378)
    at jiti (node_modules/tailwindcss/node_modules/jiti/dist/jiti.js:1:249092)
    at node_modules/tailwindcss/lib/lib/load-config.js:52:26
    at loadConfig (node_modules/tailwindcss/lib/lib/load-config.js:62:6)
    at Zne (node_modules/prettier-plugin-tailwindcss/dist/index.mjs:2487:17944)
    at async WL (node_modules/prettier-plugin-tailwindcss/dist/index.mjs:2487:17120)
    at async Object.parse (node_modules/prettier-plugin-tailwindcss/dist/index.mjs:2487:26688)
    at async parse5 (node_modules/prettier/index.mjs:19838:11)

@ineshbose
Copy link
Collaborator

I still have error inside my app that extend a Layer.

Image
ERROR  [uncaughtException] Cannot find module '/Users/sleblanc/www/app_name/.nuxt/tailwind.config.cjs'   11:18:15 AM
Require stack:
- /Users/sleblanc/www/app_name/node_modules/tailwindcss/lib/lib/load-config.js
Occurred while linting /Users/sleblanc/www/app_name/app/app.config.ts:1
Rule: "prettier/prettier"

    Require stack:
    - node_modules/tailwindcss/lib/lib/load-config.js
    at Function._resolveFilename (node:internal/modules/cjs/loader:1225:15)
    at Function.resolve (node:internal/modules/helpers:190:19)
    at _resolve (node_modules/tailwindcss/node_modules/jiti/dist/jiti.js:1:246378)
    at jiti (node_modules/tailwindcss/node_modules/jiti/dist/jiti.js:1:249092)
    at node_modules/tailwindcss/lib/lib/load-config.js:52:26
    at loadConfig (node_modules/tailwindcss/lib/lib/load-config.js:62:6)
    at Zne (node_modules/prettier-plugin-tailwindcss/dist/index.mjs:2487:17944)
    at async WL (node_modules/prettier-plugin-tailwindcss/dist/index.mjs:2487:17120)
    at async Object.parse (node_modules/prettier-plugin-tailwindcss/dist/index.mjs:2487:26688)
    at async parse5 (node_modules/prettier/index.mjs:19838:11)

I might need more context here because we've done away with tailwind.config.cjs file in the buildDir - are you able to DM me after looking me up on the Nuxt discord please?

@Luca-Sett
Copy link

@ineshbose, did you see my comment above with a different error message?

Hi @ineshbose, I have v6.13.1 of the @nuxtjs/tailwindcss module installed in a Nuxt Layer. The module works correctly in the layer when testing with the .playground folder, but I can't get a separate Nuxt project which extends the layer to work:

 ERROR  Pre-transform error: [postcss] Cannot find module '@nuxtjs/tailwindcss/merger'                                                                            15:21:11  
Require stack:
- D:\dominate-kitchen\.nuxt\tailwind\postcss.mjs
  Plugin: vite:css
  File: D:/dominate-kitchen/node_modules/vite-plugin-vue-inspector/src/Overlay.vue?vue&type=style&index=0&scoped=31d1379f&lang.css:undefined:NaN

@ineshbose
Copy link
Collaborator

@ineshbose, did you see my comment above with a different error message?

Hi @ineshbose, I have v6.13.1 of the @nuxtjs/tailwindcss module installed in a Nuxt Layer. The module works correctly in the layer when testing with the .playground folder, but I can't get a separate Nuxt project which extends the layer to work:

 ERROR  Pre-transform error: [postcss] Cannot find module '@nuxtjs/tailwindcss/merger'                                                                            15:21:11  
Require stack:
- D:\dominate-kitchen\.nuxt\tailwind\postcss.mjs
  Plugin: vite:css
  File: D:/dominate-kitchen/node_modules/vite-plugin-vue-inspector/src/Overlay.vue?vue&type=style&index=0&scoped=31d1379f&lang.css:undefined:NaN

Apologies! Could you open a new issue please? 🙏

@Luca-Sett
Copy link

No worries at all! Of course 👍

@mrleblanc101
Copy link

My issue here was with tailwindcss class sorting.
I run prettier via @nuxtjs/eslint with prettier-plugin-tailwindcss.
But to do this, you need to pass the tailwind config path to the plugin.
Since my tailwind config is inside my Layer, and not inside my individual Apsp, I was linking to the build-time config inside the .nuxt folder.
v6.13 of @nuxtjs/tailwindcss changed how this file is generated, so I needed to update the path.

{
    "printWidth": 120,
    "tabWidth": 4,
    "semi": true,
    "singleQuote": true,
    "trailingComma": "all",
    "quoteProps": "consistent",
    "bracketSameLine": false,
    "plugins": ["prettier-plugin-tailwindcss"],
-    "tailwindConfig": "./.nuxt/tailwind.config.cjs"
+    "tailwindConfig": "./.nuxt/tailwind/postcss.mjs"
}

@nethriis
Copy link

So we don't have intellisense for tailwind classes now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants