本文介绍了cleancss 命令不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在本地安装了 clean-css 但我的 npm 脚本抛出错误,因为没有找到 cleancss(sh: cleancss: command not found).我尝试直接从命令行运行 cleancss 并全局安装它(npm install -g clean-css),但我的 shell 仍然不知道它.所有其他包工作正常.这是我的 package.json 的样子:

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"
  }
}

我错过了什么?

推荐答案

来自 clean-css 文档:

clean-css 4.0 引入了一些重大变化:

  • API 和 CLI 接口是分开的,所以 API 保留在这个存储库中,而 CLI 移动到 clean-css-cli;

您只安装了 API.您需要安装 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

卸载仅 API 版本并安装 CLI.

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

这篇关于cleancss 命令不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-01 14:01