npmnpm-installclean-css

cleancss command not working


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?


Solution

  • 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.