D
Deno

help

Using Deno.Command to run tailwindcss with watch flag not working

KKyleJune1/11/2024
If I do new Deno.Command(Deno.execPath(), {args:["run", "-A", "npm:tailwindcss", "-i", "./styles.css", "-o", "./public/styles.css", "--watch"]}), no watching happens and the output file doesn't get updated. The npm package running doesn't seem to get the watch argument or the output anymore. But if I run npx tailwindcss -i ./styles.css -o ./public/styles.css --watch, It updates the file and watches for changes based on the tailwind.config.js. Is this expected or am I doing something wrong? I'm just trying to spawn a process to do the same as npx. Should I just use "npx" instead of Deno.execPath()?
DAHDeno AI Helper1/11/2024
I wasn't able to find the answer to your question in the official Deno documentation. However, based on the information you've provided in your message, I can offer some general advice. When using Deno.Command, you are constructing a command to be executed by Deno's runtime. The Deno.execPath() function returns the path to the Deno executable, which is not the same as the npx command. The npx command is a Node.js package runner, and it's not directly related to Deno. If you want to run an npm package like tailwindcss using Deno, you might need to use a different approach since Deno does not natively support npm packages. However, since you are trying to use npm:tailwindcss, it seems like you are attempting to use an npm package within Deno, which is not standard practice. One potential issue with your command is that you are using Deno.execPath() which will execute Deno itself, not npx or tailwindcss. If you want to execute npx within Deno, you would need to specify the path to the npx executable, not Deno.execPath(). Please note that this advice is not based on the Deno documentation, and I would advise you to double-check the accuracy of this advice. If you are trying to integrate Tailwind CSS with a Deno project, you might need to look for Deno-specific solutions or consider using a different approach to run the Tailwind CLI.
KKyleJune1/11/2024
Does tailwindcss not have a binary? I just noticed this says it has to have a binary for deno to run it. https://docs.deno.com/runtime/manual/node/npm_specifiers#npm-executable-scripts Actually I just checked tailwindcss, it does have a bin. So it's not that. https://www.npmjs.com/package/tailwindcss?activeTab=code

Looking for more? Join the community!