Tôi chỉ bắt tay với Gulp.js và đây là lỗi duy nhất mà tôi không thể có được.Gulp - TypeError: Không thể gán cho chỉ đọc thuộc tính 'cwd' của bower/bootstrap.css
Tôi đã cài đặt trình khởi động qua bower và tôi đang cố gắng rút gọn css bootstrap.
Đây là nhiệm vụ nuốt chửng của tôi;
gulp.task('minifycss', function() {
gulp.src('www/css/animate.css', 'www/bower_components/bootstrap/dist/css/bootstrap.css')
.pipe(minifycss({compatibility: 'ie8'}))
.pipe(gulp.dest('www-deploy/css/'));
});
Tuy nhiên, khi tôi chạy tác vụ chính của gulp. Nó nói rằng các tập tin được "chỉ đọc"
Karls-MacBook-Pro:cmp-2015 karltaylor$ gulp
[13:48:50] Using gulpfile ~/Documents/web/cmp-2015/gulpfile.js
[13:48:50] Starting 'sassMin'...
[13:48:50] Finished 'sassMin' after 12 ms
[13:48:50] Starting 'minifycss'...
[13:48:50] 'minifycss' errored after 508 μs
[13:48:50] TypeError: Cannot assign to read only property 'cwd' of www/bower_components/bootstrap/dist/css/bootstrap.css
at Object.gs.createStream (/Users/karltaylor/Documents/web/cmp-2015/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-stream/index.js:19:46)
at Object.gs.create (/Users/karltaylor/Documents/web/cmp-2015/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-stream/index.js:68:42)
at Gulp.src (/Users/karltaylor/Documents/web/cmp-2015/node_modules/gulp/node_modules/vinyl-fs/lib/src/index.js:33:23)
at Gulp.<anonymous> (/Users/karltaylor/Documents/web/cmp-2015/gulpfile.js:35:7)
at module.exports (/Users/karltaylor/Documents/web/cmp-2015/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:34:7)
at Gulp.Orchestrator._runTask (/Users/karltaylor/Documents/web/cmp-2015/node_modules/gulp/node_modules/orchestrator/index.js:273:3)
at Gulp.Orchestrator._runStep (/Users/karltaylor/Documents/web/cmp-2015/node_modules/gulp/node_modules/orchestrator/index.js:214:10)
at /Users/karltaylor/Documents/web/cmp-2015/node_modules/gulp/node_modules/orchestrator/index.js:279:18
at finish (/Users/karltaylor/Documents/web/cmp-2015/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:21:8)
at module.exports (/Users/karltaylor/Documents/web/cmp-2015/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:60:3)
Những điều tôi đã cố gắng:
- Cài đặt lại bootstrap
- Di chuyển các tập tin bootstrap.css thực tế để tập tin css của tôi, tuy nhiên nó không chính xác giống nhau cả thôi.
CHỈNH SỬA: SOLVED = Để sử dụng nhiều nguồn bạn phải đặt chúng vào một mảng.
Nguồn: https://github.com/gulpjs/gulp/blob/master/docs/recipes/using-multiple-sources-in-one-task.md
Tôi nghĩ rằng điều này xảy ra bởi vì bạn có hai f ile trong gulp.src của bạn. Hãy thử dòng này để xác minh (thay thế dòng gulp.src của bạn): 'return gulp.src ('www/bower_components/bootstrap/dist/css/bootstrap.css')' –
@topleft đã thực hiện điều này! Khi sử dụng nhiều tệp nguồn có vẻ như bạn phải đặt nó bên trong một mảng hoặc sử dụng hợp nhất luồng. - https://github.com/gulpjs/gulp/blob/master/docs/recipes/using-multiple-sources-in-one-task.md –
đặt chúng vào mảng giải quyết được sự cố. gulp.src ([,]) – Deke