我想将图像和管道压缩到构建目录,但运行任务后构建文件夹为空。这是我的任务:
// Gulp.js configuration
// modules
const gulp = require('gulp')
const newer = require('gulp-newer')
const imagemin = require('gulp-imagemin')
// development mode?
// let devBuild = (process.env.NODE_ENV !== 'production')
// folders
const folder = {
src: 'src/',
build: 'build/'
}
gulp.task('images', function () {
var out = folder.build + 'images/'
return gulp.src(folder.src + 'images/**/*')
.pipe(newer(out))
.pipe(imagemin({optimizationLevel: 5}))
.pipe(gulp.dest(out))
})
尝试运行时出现错误,gulp images
但/node_modules/jpegtran-bin/vendor/jpegtran
在node_modules
[10:07:18] Using gulpfile ~/Desktop/MyProjects/project1/gulpfile.js
[10:07:18] Starting 'images'...
events.js:182
throw er; // Unhandled 'error' event
^
Error: spawn /home/toantd/Desktop/MyProjects/project1/node_modules/jpegtran-bin/vendor/jpegtran ENOENT
at exports._errnoException (util.js:1026:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:189:19)
at onErrorNT (internal/child_process.js:366:16)
at _combinedTickCallback (internal/process/next_tick.js:102:11)
at process._tickCallback (internal/process/next_tick.js:161:9)
我还尝试通过以下链接解决此问题:
有我的项目结构:
.
├── build
│ ├── css
│ ├── html
│ ├── images
│ └── js
├── gulpfile.js
├── package.json
├── src
│ ├── html
│ ├── images
│ │ ├── bg.jpg
│ │ └── my-logo.png
│ ├── js
│ └── scss
└── yarn.lock
注意到我在公司代理下工作,但我确定我已经为 npm 和 git 设置了代理。
谁能帮我?先感谢您。