cleancss command not working

泪湿孤枕 提交于 2020-01-01 06:45:30

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/41899997/cleancss-command-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!