Build fails with "tailwind: not found" error despite correct local setup

Hi Netlify Support Team,

I’m encountering an issue with my site build on Netlify. Locally, everything works perfectly: Tailwind CSS builds without any problems. However, during the Netlify build process, I get the following error:

sh: 1: tailwind: not found

My build command in netlify.toml is:

npm install && CI=1 npm run build

And in my package.json, the build script is:

“build”: “npx tailwindcss -i ./src/input.css -o ./dist/output.css --minify”

Despite this, the Netlify build cannot find the tailwindcss binary.
Here is my log:

10:37:28 AM: Netlify Build
10:37:28 AM: ────────────────────────────────────────────────────────────────
10:37:28 AM: ​
10:37:28 AM: ❯ Version
10:37:28 AM: @netlify/build 33.4.6
10:37:28 AM: ​
10:37:28 AM: ❯ Flags
10:37:28 AM: accountId: 684ea49c660dddb923f86e59
10:37:28 AM: baseRelDir: true
10:37:28 AM: buildId: 684fd79c2bf3200008d091b4
10:37:28 AM: deployId: 684fd79c2bf3200008d091b6
10:37:29 AM: ​
10:37:29 AM: ❯ Current directory
10:37:29 AM: /opt/build/repo
10:37:29 AM: ​
10:37:29 AM: ❯ Config file
10:37:29 AM: /opt/build/repo/netlify.toml
10:37:29 AM: ​
10:37:29 AM: ❯ Context
10:37:29 AM: production
10:37:29 AM: ​
10:37:29 AM: build.command from netlify.toml
10:37:29 AM: ────────────────────────────────────────────────────────────────
10:37:29 AM: ​
10:37:29 AM: $ npm install && CI=1 npm run build
10:37:29 AM: up to date, audited 133 packages in 453ms
10:37:29 AM: 38 packages are looking for funding
10:37:29 AM: run npm fund for details
10:37:29 AM: found 0 vulnerabilities
10:37:29 AM: > doodleidoo@1.0.0 build
10:37:29 AM: > npx tailwindcss -i ./src/input.css -o ./dist/output.css --minify
10:37:29 AM: sh: 1: tailwind: not found
10:37:29 AM: ​
10:37:29 AM: “build.command” failed
10:37:29 AM: ────────────────────────────────────────────────────────────────
10:37:29 AM: ​
10:37:29 AM: Error message
10:37:29 AM: Command failed with exit code 127: npm install && CI=1 npm run build (Search results for '"non-zero exit code: 127"' - Netlify Support Forums)
10:37:29 AM: ​
10:37:29 AM: Error location
10:37:29 AM: In build.command from netlify.toml:
10:37:29 AM: npm install && CI=1 npm run build
10:37:29 AM: ​
10:37:29 AM: Resolved config
10:37:29 AM: build:
10:37:29 AM: command: npm install && CI=1 npm run build
10:37:29 AM: commandOrigin: config
10:37:29 AM: publish: /opt/build/repo/dist
10:37:29 AM: publishOrigin: config
10:37:29 AM: functionsDirectory: /opt/build/repo/netlify/functions
10:37:30 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
10:37:30 AM: Failing build: Failed to build site
10:37:30 AM: Finished processing build request in 15.13s
10:37:30 AM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2 (Search results for '"non-zero exit code: 2"' - Netlify Support Forums)

I have verified that tailwindcss is correctly installed as a dev dependency in my project. The node_modules folder is properly installed during the build.

Could you please help me understand why Netlify cannot locate the Tailwind CLI and how to fix this issue?

Thank you for your support.

Best regards,

The docs say something very different: Tailwind CLI - Tailwind CSS, specifically:

So, npx tailwindcss -i ./src/input.css -o ./dist/output.css --minify is incorrect.

Hello @hrishikesh,
Thanks for taking time to answer.

I’ve already try, I just did : it’s the same with --watch :

8:05:26 AM: Netlify Build
8:05:26 AM: ────────────────────────────────────────────────────────────────
8:05:26 AM: ​
8:05:26 AM: ❯ Version
8:05:26 AM: @netlify/build 33.4.6
8:05:26 AM: ​
8:05:26 AM: ❯ Flags
8:05:26 AM: accountId: 684ea49c660dddb923f86e59
8:05:26 AM: baseRelDir: true
8:05:26 AM: buildId: 685105963f0d300008fc809f
8:05:26 AM: deployId: 685105963f0d300008fc80a1
8:05:26 AM: ​
8:05:26 AM: ❯ Current directory
8:05:26 AM: /opt/build/repo
8:05:26 AM: ​
8:05:26 AM: ❯ Config file
8:05:26 AM: /opt/build/repo/netlify.toml
8:05:26 AM: ​
8:05:26 AM: ❯ Context
8:05:26 AM: production
8:05:26 AM: ​
8:05:26 AM: build.command from netlify.toml
8:05:26 AM: ────────────────────────────────────────────────────────────────
8:05:26 AM: ​
8:05:26 AM: $ npm install && CI=1 npm run build
8:05:27 AM: up to date, audited 133 packages in 387ms
8:05:27 AM: 38 packages are looking for funding
8:05:27 AM: run npm fund for details
8:05:27 AM: found 0 vulnerabilities
8:05:27 AM: > doodleidoo@1.0.0 build
8:05:27 AM: > npx tailwindcss -i ./src/input.css -o ./dist/output.css --watch
8:05:27 AM: sh: 1: tailwind: not found
8:05:27 AM: ​
8:05:27 AM: “build.command” failed
8:05:27 AM: ────────────────────────────────────────────────────────────────
8:05:27 AM: ​
8:05:27 AM: Error message
8:05:27 AM: Command failed with exit code 127: npm install && CI=1 npm run build (Search results for '"non-zero exit code: 127"' - Netlify Support Forums)
8:05:27 AM: ​
8:05:27 AM: Error location
8:05:27 AM: In build.command from netlify.toml:
8:05:27 AM: npm install && CI=1 npm run build
8:05:27 AM: ​
8:05:27 AM: Resolved config
8:05:27 AM: build:
8:05:27 AM: command: npm install && CI=1 npm run build
8:05:27 AM: commandOrigin: config
8:05:27 AM: publish: /opt/build/repo/dist
8:05:27 AM: publishOrigin: config
8:05:27 AM: functionsDirectory: /opt/build/repo/netlify/functions
8:05:28 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
8:05:28 AM: Failing build: Failed to build site
8:05:28 AM: Finished processing build request in 15.437s
8:05:28 AM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2 (Search results for '"non-zero exit code: 2"' - Netlify Support Forums)

I’ve changed the repositories for html and css, and now the build is ok.
Thanks for helping me.