环境:
- Windows 7
- Node 6.9.5
我使用像这个npm的插件。但是我遇到了一个错误。从一些视频中得知,它是正确的。这与imagemin的版本有关吗?
// gulpfile.js
var gulp = require('gulp');
var imagemin = require('gulp-imagemin');
var app = {
srcPath: 'src/',
devPath: 'build/',
prdPath: 'dist/', //生产部署
}
gulp.task('image', function() {
gulp.src(app.srcPath + 'image/**/*')
.pipe(gulp.dest(app.devPath + 'image'))
.pipe(imagemin())
.pipe(gulp.dest(app.prdPath + 'image'))
})
当我运行命令 "gulp image" 时,出现错误:
[13:05:56] Using gulpfile ~\Desktop\study\angularapp\gulpfile.js
[13:05:56] Starting 'image'...
[13:05:56] Finished 'image' after 6.96 ms
[13:05:56] gulp-imagemin: Couldn't load default plugin "gifsicle"
[13:05:56] gulp-imagemin: Couldn't load default plugin "jpegtran"
[13:05:56] gulp-imagemin: Couldn't load default plugin "optipng"
[13:05:56] gulp-imagemin: Minified 1 image (saved 0 B - 0%)
我使用 npm install imagemin-optipng
,但它仍然无法正常工作。类似这样的依赖关系:
"devDependencies": {
"clean-css": "^4.0.5",
"gulp": "^3.9.1",
"gulp-clean": "^0.3.2",
"gulp-concat": "^2.6.1",
"gulp-connect": "^5.0.0",
"gulp-cssmin": "^0.1.7",
"gulp-imagemin": "^3.1.1",
"gulp-less": "^3.3.0",
"gulp-load-plugins": "^1.5.0",
"gulp-uglify": "^2.0.1",
"lodash": "^4.17.4",
"open": "^0.0.5"
它发生了什么事情?
npm uninstall gulp-imagemin
),然后重新安装 (npm install -D gulp-imagemin
),看看在安装过程中是否有任何错误? - henry