Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

django-tailwind cannot find the npm executable (cPanel, Windows, Linux)

Errorpython manage.py tailwind install fails because npm or Node.js cannot be found

Short answer

django-tailwind runs npm as a subprocess, and Python sometimes cannot find it. Set NPM_BIN_PATH in settings.py to the full path of npm (npm.cmd on Windows). Make sure Node.js is version 22 or newer. On shared hosting without Node.js, run tailwind build elsewhere and deploy the CSS.

  • Applies to django-tailwind (current release), Node.js 22
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Ask the same environment that runs Django where npm is. If this prints nothing, Python cannot see npm either, and the first cause applies.

    which npm
    node --version
  2. 2Match what you see, then jump to its fix

    1. 1npm works in your terminal, but the manage.py command cannot find it (the docs name Windows as the common case)Python cannot find npm, so NPM_BIN_PATH is neededFix
    2. 2npm cannot be found at all, or node --version prints a version below 22Node.js is missing or older than the version Tailwind needsFix
    3. 3Shared hosting where you cannot install Node.js, and tailwind commands are only needed to produce CSSThe server has no Node.js at all, so build the CSS elsewhereFix

What does the error look like?

  • python manage.py tailwind install fails because npm or Node.js cannot be found
  • CommandError raised by the tailwind management command about npm

Cause 1 of 3

Python cannot find npm, so NPM_BIN_PATH is needed

1Check

The package docs say the Python executable sometimes cannot find the npm binary, especially on Windows. On Windows, npm may be on PATH as npm.cmd rather than npm. To get the path use which npm (Linux or macOS), or where npm or Get-Command npm on Windows.

which npm

2Fix

Set NPM_BIN_PATH in settings.py. A fully qualified path is the most reliable form.

# settings.py  (Linux / macOS)
NPM_BIN_PATH = "/usr/local/bin/npm"

# settings.py  (Windows)
NPM_BIN_PATH = r"C:\Program Files\nodejs\npm.cmd"

3Verify

Run the install command again.

python manage.py tailwind install

Confirmed by django-tailwind.readthedocs.io

Did this fix it?

Cause 2 of 3

Node.js is missing or older than the version Tailwind needs

1Check

For npm-based installs the package docs say Tailwind CSS requires Node.js 22 or newer on the machine. On cPanel, the Application Manager page lists the Node.js packages ea-nodejs16, 18, 20 and 22, and installing one removes the other Node.js packages.

node --version

2Fix

Install Node.js 22 or newer (on cPanel, the ea-nodejs22 package, if your host allows it), then set NPM_BIN_PATH to the npm that belongs to it.

node --version
which npm

3Verify

Install the dependencies and start the watcher.

python manage.py tailwind install
python manage.py tailwind start

Confirmed by docs.cpanel.net

Did this fix it?

Cause 3 of 3

The server has no Node.js at all, so build the CSS elsewhere

1Check

The usage page says python manage.py tailwind build replaces the development build with a production-optimised CSS bundle, and that no further action is needed before you deploy.

python manage.py tailwind build

2Fix

Run the build on your own machine (or in CI) where Node.js 22 is installed, then deploy the generated CSS with the rest of the project. The live server then only runs Django.

# on the machine with Node.js
python manage.py tailwind install
python manage.py tailwind build

3Verify

Open the deployed page and confirm the Tailwind styles load.

curl -I https://example.com/

Confirmed by django-tailwind.readthedocs.io

Did this fix it?

How do I stop it coming back?

  • Pin the Node.js major version for the project (in your docs or CI) so every machine matches.
  • Set NPM_BIN_PATH from an environment variable in settings.py so dev, CI and server can each point to their own npm.
  • Run tailwind build in the deploy pipeline instead of on the live host.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Web apps

CORS fails when you open an HTML file straight from disk

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///

A page opened from disk has an opaque origin, so browsers treat every request it makes as cross-origin, and CORS only works over http or https.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.