timonweb / django-tailwind

Django + Tailwind CSS = 💚
https://django-tailwind.readthedocs.io
MIT License
1.46k stars 92 forks source link

Issue building tailwind css on windows 10 #48

Closed OliverGeneser closed 3 years ago

OliverGeneser commented 3 years ago

Hey guys!

When I run the command 'Python manage.py tailwind build' I get the following error:

'NODE_ENV' is not recognized as an internal or external command, operable program or batch file. npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! django_tailwind@ build:postcss: NODE_ENV=production postcss --config . --map false --output ../static/css/styles.css ../static/css/styles.css npm ERR! Exit status 1 npm ERR!

Running the 'tailwind start' command works fine.

I have already set my NPM_BIN_PATH in settings.

timonweb commented 3 years ago

It seems like on windows NODE_ENV=production doesn't work. I see that using something like cross-env would be the solution for all users, but until I implement that, you can do a manual fix, here's how:

  1. Edit theme/static_src/package.json file
  2. Find the following line there:
    "build:postcss": "NODE_ENV=production postcss --config . --map false --output ../static/css/styles.css ../static/css/styles.css",
  3. Change it to look like:
    "build:postcss": "SET NODE_ENV=production && postcss --config . --map false --output ../static/css/styles.css ../static/css/styles.css",

I don't have Windows, so this is untested, but should work. Please try it and let me know here if it has solved the issue.

timonweb commented 3 years ago

Hey, I just went ahead and added cross-env so you have two options: either complete steps outlined above, or upgrade to the latest django-tailwind v1.1.1 and init a tailwind project once again.

OliverGeneser commented 3 years ago

Thanks a lot! I went ahead abd update django-tailwind and it now works perfectly!

timonweb commented 3 years ago

Great, thanks for the confirmation!