shufo / blade-formatter

An opinionated blade template formatter for Laravel that respects readability
https://www.npmjs.com/package/blade-formatter
MIT License
456 stars 25 forks source link

[Bug]: `message: "Cannot find module 'tailwindcss/defaultTheme'"` #814

Closed bilogic closed 1 year ago

bilogic commented 1 year ago

Description

I installed blade-formatter globally to /usr/bin, using npm set prefix /usr, i.e.

npm set prefix /usr
npm install -g blade-formatter

# which blade-formatter
/usr/bin/blade-formatter

Each time I run it with --sort-tailwindcss-classes, I get there error message: "Cannot find module 'tailwindcss/defaultTheme'"

Without --sort-tailwindcss-classes, blade-formatter formats correctly.

Expected Behavior

blade-formatter should format without error

Actual Behavior

blade-formatter throws message: "Cannot find module 'tailwindcss/defaultTheme'"

Additional Context

No response

bilogic commented 1 year ago

More info provided in the OP update. Thank you.

shufo commented 1 year ago

Thanks for creating the issue @bilogic I could not reproduce in my environment but it might be there have not tailwindcss module in global.

shufo commented 1 year ago

Global installation is a little complicated to resolve dependencies, so I would recommend using local dependencies if possible.

$ cd your_project
$ npm install --save-dev blade-formatter tailwindcss
$ ./node_modules/.bin/blade-formatter --sort-tailwindcss-classes target.blade.php
bilogic commented 1 year ago

Hey thanks! I managed to resolve the issue already, can't remember how though. Haha