3

I installed clean-css locally but my npm script is throwing an error because cleancss is not found (sh: cleancss: command not found). I tried running cleancss straight from the command line and installed it globally (npm install -g clean-css) but my shell still doesn't know about it. All other packages are working fine. Here's what my package.json looks like:

{
  "scripts": {
    "lint": "echo '=> linting' && jshint **/*.js",
    "minify:js": "echo '=> minify:js' && uglifyjs main.js -o public/js/main.min.js",
    "minify": "echo '=> minify:css' && cleancss main.css -o public/css/main.min.css"
  },
  "devDependencies": {
    "clean-css": "^4.0.2",
    "jshint": "^2.9.4",
    "uglify-js": "^2.7.5"
  }
}

What am I missing?

mrtnmgs
  • 1,402
  • 14
  • 26

1 Answers1

15

From the clean-css docs:

clean-css 4.0 introduces some breaking changes:

  • API and CLI interfaces are split, so API stays in this repository while CLI moves to clean-css-cli;

You have only the API installed. You need to install the CLI. Run:

npm install --save-dev clean-css-cli
npm uninstall --save-dev clean-css

To uninstall the API-only version and install the CLI.

RyanZim
  • 6,609
  • 1
  • 27
  • 43
  • That was it! Thanks for your help! – mrtnmgs Jan 28 '17 at 17:12
  • 1
    For Sublime Text, the _Minify_ package stopped minifying CSS files because it could not find the `clean-css\bin\cleancss`. After reading your answer, I just tried `npm install -g clean-css-cli` and the reference seems to have been automatically fixed. It works, thanks! – Armfoot Sep 11 '17 at 22:25
  • npm i -g clean-css-cli – abe312 Jul 16 '18 at 19:26