artpods56
artpods562mo ago

Cant configure Tailwind with DaisyUI using Deno inside of Docker | Error: Cannot find module daisyui

I'm literally pulling my hair right now because i can't figure out why is it not working in my case. I got tailwind to work but i can't figure out why the DaisyUI can't be found. Im using docker for local development and here is my config related to deno. deno.json
{
"imports": {
"tailwindcss": "npm:tailwindcss@latest",
"daisyui": "npm:daisyui@latest",
"postcss": "npm:postcss@latest",
"autoprefixer": "npm:autoprefixer@latest"
},
"tasks": {
"build:css": "deno run -A npm:tailwindcss -i ./src/styles.css -o /static/styles.css --minify --watch"
},

"exclude": [
"dist/"
]

}

{
"imports": {
"tailwindcss": "npm:tailwindcss@latest",
"daisyui": "npm:daisyui@latest",
"postcss": "npm:postcss@latest",
"autoprefixer": "npm:autoprefixer@latest"
},
"tasks": {
"build:css": "deno run -A npm:tailwindcss -i ./src/styles.css -o /static/styles.css --minify --watch"
},

"exclude": [
"dist/"
]

}

tailwind.package.js
/** @type {import('tailwindcss').Config} */


module.exports = {
content: ["/templates/**/*.{html,js}"],
theme: {
extend: {},
},
plugins: [require("daisyui")],
}
/** @type {import('tailwindcss').Config} */


module.exports = {
content: ["/templates/**/*.{html,js}"],
theme: {
extend: {},
},
plugins: [require("daisyui")],
}
Error message from container logs
Attaching to django_demo, deno-1
deno-1 | Task build:css deno run -A npm:tailwindcss -i ./src/styles.css -o /static/styles.css --minify --watch
deno-1 |
deno-1 | Rebuilding...
deno-1 | Searching for config: 0.110ms
deno-1 | Module dependencies: 0.002ms
deno-1 | Error: Cannot find module 'daisyui'
deno-1 | Require stack:
deno-1 | - /deno/tailwind.config.js
deno-1 | at Function.Module._resolveFilename (node:module:619:15)
deno-1 | at Function.resolve (node:module:821:19)
deno-1 | at _resolve (file:///deno-dir/npm/registry.npmjs.org/jiti/1.21.6/dist/jiti.js:1:242050)
deno-1 | at loadConfig (file:///deno-dir/npm/registry.npmjs.org/tailwindcss/3.4.15/lib/lib/load-config.js:58:6) {
deno-1 | code: "MODULE_NOT_FOUND",
deno-1 | requireStack: [ "/deno/tailwind.config.js" ]
deno-1 | }
Attaching to django_demo, deno-1
deno-1 | Task build:css deno run -A npm:tailwindcss -i ./src/styles.css -o /static/styles.css --minify --watch
deno-1 |
deno-1 | Rebuilding...
deno-1 | Searching for config: 0.110ms
deno-1 | Module dependencies: 0.002ms
deno-1 | Error: Cannot find module 'daisyui'
deno-1 | Require stack:
deno-1 | - /deno/tailwind.config.js
deno-1 | at Function.Module._resolveFilename (node:module:619:15)
deno-1 | at Function.resolve (node:module:821:19)
deno-1 | at _resolve (file:///deno-dir/npm/registry.npmjs.org/jiti/1.21.6/dist/jiti.js:1:242050)
deno-1 | at loadConfig (file:///deno-dir/npm/registry.npmjs.org/tailwindcss/3.4.15/lib/lib/load-config.js:58:6) {
deno-1 | code: "MODULE_NOT_FOUND",
deno-1 | requireStack: [ "/deno/tailwind.config.js" ]
deno-1 | }
I would really appreciate any help as I'm pretty close to giving up..
10 Replies
2saturdayscode
2saturdayscode2mo ago
I guess that tailwind tries to look into node_modules folder to resolve daisyui but it doesn't find it because deno does not use the node_modules dir Try add this to your deno.json config:
"nodeModulesDir": "auto",
"nodeModulesDir": "auto",
artpods56
artpods56OP2mo ago
I feel like something like this should be mentioned somewhere in the documentation. It stated to work after this but the amount of time i spent on searching for solution.. Thank you!
2saturdayscode
2saturdayscode2mo ago
You are most welcomed! The issue is that it's very hard to account for the very wide and often bizarre behavior of the node ecosystem and all the issues you will encounter with Deno will highlight what a mess it is!
Marky
Marky4w ago
Thans for this, but is this good practice?
2saturdayscode
This is a legit and the official way to have compatibility with node stuff, it’s not magic it just downloads the stuff from npm and saves it there, you would get the same result if you opted in vendoring (ie save the deps in your repo so you can upload it in your deploys. It would create a node_modules dir but also a vendor dir too for non-npm des) so really nothing to worry about
Fifth-Normal-Form
This is great info, and will help me in the future. Thanks for this.
Marky
Marky4w ago
works fine but it causes this error for me when
"nodeModulesDir": "auto",
"nodeModulesDir": "auto",
No description
No description
2saturdayscode
Instead of import "typed-htmx" try import type {} from "typed-htmx"
Marky
Marky4w ago
still got this
No description
2saturdayscode
Iknow it sounds unusual but did you try to restart the deno server language?