请指教我想用gulp缩小我的项目的.css文件,所以我在gulp.js文件中写了下面的任务,如下所示,但仍然在执行时我收到错误,请告知如何修复低于错误
下面是我写的代码是
var gulp = require('gulp');
var minifyCss = require("gulp-minify-css");
gulp.task('minify-css', function () {
gulp.src('C:\\Softwares\\Spring4MVCAngularJSExample\\target\\Spring4MVCAngularJSExample\\static\\css\\*.css') // path to your file
.pipe(minifyCss())
.pipe(gulp.dest('C:\\Softwares\\Spring4MVCAngularJSExample\\target\\Spring4MVCAngularJSExample\\static\\cssoutput'));
});
下面是我执行时的错误
C:\Softwares\Spring4MVCAngularJSExample>gulp minify-css
module.js:471
throw err;
^
Error: Cannot find module 'gulp-minify-css'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Softwares\Spring4MVCAngularJSExample\gulpfile.js:10:13)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
答案 0 :(得分:0)
似乎找不到模块。你运行npm install gulp-minify-css --save-dev
?
您可能想尝试重新安装本地软件包/依赖项:
rm -rf node_modules/
npm install