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

cli: Reading from stdin is broken in 4.0.0-alpha.25 #14521

Closed
bep opened this issue Sep 26, 2024 · 2 comments · Fixed by #14522
Closed

cli: Reading from stdin is broken in 4.0.0-alpha.25 #14521

bep opened this issue Sep 26, 2024 · 2 comments · Fixed by #14522
Assignees
Labels

Comments

@bep
Copy link

bep commented Sep 26, 2024

mkdir tailwindtest
cd tailwindtest
npm i @tailwindcss/cli@4.0.0-alpha.25 tailwindcss@4.0.0-alpha.25 --save-dev
echo "@import 'tailwindcss';" > foo.css

This works:

npx tailwindcss  -i foo.css -o bar.css

This fails:

npx tailwindcss  --input=- -o bar.css < foo.css

Output:

~/d/tailwindbug ❯❯❯ npx tailwindcss  --input=- -o bar.css < foo.css                                                                             main ✱ ◼
/Users/bep/dump/tailwindbug/node_modules/enhanced-resolve/lib/Resolver.js:564
			const error = new Error("Can't " + message);
			             ^

Error: Can't resolve 'tailwindcss' in '/Users/bep/dump'
    at finishWithoutResolve (/Users/bep/dump/tailwindbug/node_modules/enhanced-resolve/lib/Resolver.js:564:18)
    at /Users/bep/dump/tailwindbug/node_modules/enhanced-resolve/lib/Resolver.js:656:15
    at /Users/bep/dump/tailwindbug/node_modules/enhanced-resolve/lib/Resolver.js:718:5
    at eval (eval at create (/Users/bep/dump/tailwindbug/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
    at /Users/bep/dump/tailwindbug/node_modules/enhanced-resolve/lib/Resolver.js:718:5
    at eval (eval at create (/Users/bep/dump/tailwindbug/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:16:1)
    at /Users/bep/dump/tailwindbug/node_modules/enhanced-resolve/lib/Resolver.js:718:5
    at eval (eval at create (/Users/bep/dump/tailwindbug/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
    at /Users/bep/dump/tailwindbug/node_modules/enhanced-resolve/lib/Resolver.js:718:5
    at eval (eval at create (/Users/bep/dump/tailwindbug/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1) {
  details: "resolve 'tailwindcss' in '/Users/bep/dump'\n" +
    '  Parsed request is a module\n' +
    '  No description file found in /Users/bep/dump or above\n' +
    '  resolve as module\n' +
    "    /Users/bep/dump/node_modules doesn't exist or is not a directory\n" +
    "    /Users/bep/node_modules doesn't exist or is not a directory\n" +
    "    /Users/node_modules doesn't exist or is not a directory\n" +
    "    /node_modules doesn't exist or is not a directory"

Downgrading to alpha 24 and it works:

npm i @tailwindcss/cli@4.0.0-alpha.24 tailwindcss@4.0.0-alpha.24 --save-dev
npx tailwindcss  --input=- -o bar.css < foo.css
@philipp-spiess
Copy link
Member

@bep Thanks for the bug report! There's an issue in the base path it uses when configured with stdin input files. Will put out a fix shorty!

philipp-spiess added a commit that referenced this issue Sep 26, 2024
Fixes #14521

When using the CLI to read files from `stdin` like this:

```bash
npx tailwindcss  --input=- -o bar.css < foo.css
```

We need to set the `base` path to be the current working directory
(`process.cwd()`). However, `cwd()` already _is_ a directory and calling
`dirname()` on it did go to the parent directory _which might not have
the `tailwindcss` dependency installed.
@philipp-spiess
Copy link
Member

@bep Merged a fix for this now, it will be part of the next patch release. Thank you again!

bep added a commit to bep/hugo-testing-tailwindcss-v4 that referenced this issue Sep 27, 2024
And add a note about the broken upstream.

See tailwindlabs/tailwindcss#14521
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.

2 participants