我在本地安装了clean-css,但我的npm脚本抛出错误,因为找不到cleancss(sh:cleancss:command not found). 我尝试直接从命令行运行cleancss并全局安装(npm install -g clean-css)但我的 shell仍然不知道它.所有
我尝试直接从命令行运行cleancss并全局安装(npm install -g clean-css)但我的 shell仍然不知道它.所有其他包都工作正常.
这是我的package.json的样子:
{ "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 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 07001;
您只安装了API.您需要安装CLI.跑:
npm install --save-dev clean-css-cli npm uninstall --save-dev clean-css
卸载仅API版本并安装CLI.