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

[v4] Standalone cli doesn't bundle tailwindcss js library #15235

Open
leifmetcalf opened this issue Nov 29, 2024 · 9 comments · May be fixed by #15934
Open

[v4] Standalone cli doesn't bundle tailwindcss js library #15235

leifmetcalf opened this issue Nov 29, 2024 · 9 comments · May be fixed by #15934
Labels

Comments

@leifmetcalf
Copy link

leifmetcalf commented Nov 29, 2024

What version of Tailwind CSS are you using?

v4.0.0-beta.3

What build tool (or framework if it abstracts the build tool) are you using?

None

What version of Node.js are you using?

v22.8.0

What browser are you using?

N/A

What operating system are you using?

Ubuntu 24.10

Reproduction URL

https://github.com/leifmetcalf/tailwind-repro/tree/8cfa9c2b2b13a3d3e87cc115000ee553ea0a11df

Describe your issue

Run this command in the reproduction repo above

tailwindcss-linux-x64 --input app.css --output out.css

The command returns error code 1 with no message. Installing tailwind with npm install tailwindcss fixes the problem and the output file is created as expected.

@leifmetcalf leifmetcalf changed the title Tailwind standalone cli doesn't bundle tailwindcss js library Tailwind v4 standalone cli doesn't bundle tailwindcss js library Nov 29, 2024
@leifmetcalf leifmetcalf changed the title Tailwind v4 standalone cli doesn't bundle tailwindcss js library [v4] Standalone cli doesn't bundle tailwindcss js library Nov 29, 2024
@melissa59zebrowski
Copy link

melissa59zebrowski commented Jan 10, 2025

Hello,

It seems that the problem arises when using the standalone tailwindcss-linux-x64 binary directly, as opposed to installing it via npm. When running the binary, it returns error code 1 with no message, which doesn't provide much information about the root cause of the failure. However, when you install Tailwind via npm, it works correctly, generating the output file as expected.

One possible explanation could be a mismatch between the binary's expected environment or configuration and the local system setup. It may also be that the binary is not automatically handling some dependencies or configurations that the npm installation process takes care of. Additionally, error messages are sometimes omitted for issues hmfusa app like missing environment variables or misconfigured paths, which could explain why you're seeing a generic error code without more details.

@treddy73
Copy link

This problem still exists on v4.0.1. I'm using the standalone CLI tool (via homebrew) because I'm developing a site entirely in Go. It worked wonderfully prior to v4.0.0.

My v3 tailwind.config.js is extremely simple:

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [
      './internal/server/component/*.templ'
  ],
  theme: {
    extend: {},
  },
  plugins: [],
}

Likewise my v4 tailwind.css is extremely simple:

@import 'tailwindcss';
@config './tailwind.config.js'

tailwindcss -i tailwind.css -o output.css --minify produces the following error:

Error: Can't resolve 'tailwindcss' in '<project path>'

In order to unblock my development, I've had to npm install the tailwind dependencies and the above command works.

@axzilla
Copy link

axzilla commented Jan 30, 2025

This problem still exists on v4.0.1. I'm using the standalone CLI tool (via homebrew) because I'm developing a site entirely in Go. It worked wonderfully prior to v4.0.0.

My v3 tailwind.config.js is extremely simple:

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [
      './internal/server/component/*.templ'
  ],
  theme: {
    extend: {},
  },
  plugins: [],
}

Likewise my v4 tailwind.css is extremely simple:

@import 'tailwindcss';
@config './tailwind.config.js'

tailwindcss -i tailwind.css -o output.css --minify produces the following error:

Error: Can't resolve 'tailwindcss' in '<project path>'

In order to unblock my development, I've had to npm install the tailwind dependencies and the above command works.

Same here!

@stefanchrobot
Copy link

Similar issue with plugins. Adding custom plugins seems to crash Tailwind:

/* app.css */
@import "tailwindcss";
@plugin "./myplugin.js";
// myplugin.js, https://v3.tailwindcss.com/docs/plugins#adding-components
const plugin = require('tailwindcss/plugin')

module.exports = {
  plugins: [
    plugin(function({ addComponents }) {
      addComponents({
        '.btn': {
          padding: '.5rem 1rem',
          borderRadius: '.25rem',
          fontWeight: '600',
        },
      })
    })
  ]
}
tailwindcss --input app.css --output styles.css

No output is produced.

@Flo0807
Copy link

Flo0807 commented Feb 1, 2025

Hey!

I have the same error with the plugin. No output is generated if I try to add a custom plugin.

I noticed that the root cause of the error might be the following line inside my plugin file:

const plugin = require('tailwindcss/plugin')

Unfortunately, you don't need this because you can just export a basic function (no need to wrap it into plugin). I don't know if this is something Tailwind changed with v4 (?)

So instead of this:

const plugin = require('tailwindcss/plugin')

module.exports = plugin(function() {
  // your plugin code
})

try this

module.exports = function() {
  // your plugin code
}

This solves the problem for me and an output is generated (the plugin also works fine)

@pehbehbeh
Copy link

@Flo0807

I don't know if this is something Tailwind changed with v4 (?)

Yeah, the docs on this are really lacking atm...

you don't need this because you can just export a basic function

Good to know!

Unfortunately this does not work for 3rd party plugins like this one (because the import is done in the plugin code):

const { addIconSelectors } = require('@iconify/tailwind')

module.exports = addIconSelectors({
  prefixes: ["tabler"],
  scale: 1.75
})

Works perfectly fine when adding tailwindcss to node_modules.

@axzilla
Copy link

axzilla commented Feb 8, 2025

Does anyone have updates/workarounds on this topic? 🤔

@treddy73
Copy link

Does anyone have updates/workarounds on this topic? 🤔

@axzilla tailwindcss v4.0.5 is now working for the simple example I posted earlier in this thread. 👍

@axzilla
Copy link

axzilla commented Feb 12, 2025

Does anyone have updates/workarounds on this topic? 🤔

@axzilla tailwindcss v4.0.5 is now working for the simple example I posted earlier in this thread. 👍

Yeah it works now, thanks! =)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants