Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Gulp-TypeError:无法分配给只读属性';cwd&x27;bower/bootstrap.css的名称_Css_Twitter Bootstrap_Command Line_Gulp_Bower - Fatal编程技术网

Gulp-TypeError:无法分配给只读属性';cwd&x27;bower/bootstrap.css的名称

Gulp-TypeError:无法分配给只读属性';cwd&x27;bower/bootstrap.css的名称,css,twitter-bootstrap,command-line,gulp,bower,Css,Twitter Bootstrap,Command Line,Gulp,Bower,我刚刚开始处理Gulp.js,这是我唯一无法回避的错误 我已经通过bower安装了bootstrap,我正在尝试缩小bootstrap css 这是我的吞咽任务 gulp.task('minifycss', function() { gulp.src('www/css/animate.css', 'www/bower_components/bootstrap/dist/css/bootstrap.css') .pipe(minifycss({compatibility: 'ie8'}))

我刚刚开始处理Gulp.js,这是我唯一无法回避的错误

我已经通过bower安装了bootstrap,我正在尝试缩小bootstrap css

这是我的吞咽任务

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/'));
});
然而,当我运行我的主要吞咽任务时。它声明该文件为“只读”

Karls MacBook Pro:cmp-2015 karltaylor$gulp
[13:48:50]使用gulpfile~/Documents/web/cmp-2015/gulpfile.js
[13:48:50]正在启动“sassMin”。。。
[13:48:50]12毫秒后完成“sassMin”
[13:48:50]正在启动“minifycss”。。。
[13:48:50]“minifycss”在508μs后出错
[13:48:50]类型错误:无法分配给www/bower_components/bootstrap/dist/css/bootstrap.css的只读属性“cwd”
在Object.gs.createStream(/Users/karltaylor/Documents/web/cmp-2015/node_modules/gulp/node_modules/乙烯基fs/node_modules/glob stream/index.js:19:46)
在Object.gs.create(/Users/karltaylor/Documents/web/cmp-2015/node_modules/gulp/node_modules/vinyl fs/node_modules/glob stream/index.js:68:42)
在Gulp.src(/Users/karltaylor/Documents/web/cmp-2015/node_modules/Gulp/node_modules/乙烯基fs/lib/src/index.js:33:23)

大口喝。

或者你也可以尝试

return gulp.src('www/**/*.css')

它应该在你的目录中添加every.css如果这是想要的效果

就像上面提到的@topleft一样,这是因为在my gulp.src中使用多个文件的语法错误。要使用多个源,需要将它们放在一个数组中

例如:

var gulp = require('gulp');
var concat = require('gulp-concat');

gulp.task('default', function() {
    return gulp.src(['foo/*', 'bar/*'])
        .pipe(concat('result.txt'))
        .pipe(gulp.dest('build'));
});

我在尝试输出2个css文件时遇到了这个问题,但我没有使用数组[]

而不是:

gulp.src('www/css/animate.css', 'www/bower_components/bootstrap/dist/css/bootstrap.css')
    .pipe(minifycss({compatibility: 'ie8'}))
    .pipe(gulp.dest('www-deploy/css/'));
});
gulp.src(['www/css/animate.css', 'www/bower_components/bootstrap/dist/css/bootstrap.css'])
    .pipe(minifycss({compatibility: 'ie8'}))
    .pipe(gulp.dest('www-deploy/css/'));
});
gulp.src(['./file1.scss', './file2.scss']);
使用以下命令:

gulp.src('www/css/animate.css', 'www/bower_components/bootstrap/dist/css/bootstrap.css')
    .pipe(minifycss({compatibility: 'ie8'}))
    .pipe(gulp.dest('www-deploy/css/'));
});
gulp.src(['www/css/animate.css', 'www/bower_components/bootstrap/dist/css/bootstrap.css'])
    .pipe(minifycss({compatibility: 'ie8'}))
    .pipe(gulp.dest('www-deploy/css/'));
});
gulp.src(['./file1.scss', './file2.scss']);
说明:

gulp.src('www/css/animate.css', 'www/bower_components/bootstrap/dist/css/bootstrap.css')
    .pipe(minifycss({compatibility: 'ie8'}))
    .pipe(gulp.dest('www-deploy/css/'));
});
gulp.src(['www/css/animate.css', 'www/bower_components/bootstrap/dist/css/bootstrap.css'])
    .pipe(minifycss({compatibility: 'ie8'}))
    .pipe(gulp.dest('www-deploy/css/'));
});
gulp.src(['./file1.scss', './file2.scss']);

我认为这是因为gulp.src中有两个文件。尝试这一行来验证(替换gulp.src行):
return gulp.src('www/bower\u components/bootstrap/dist/css/bootstrap.css')
@topleft这就成功了!当使用多个源文件时,您必须将其放入数组中或使用合并流。-将它们放入阵列中解决了问题。gulp.src([,])在这种情况下,顺序很重要!那你就做不到了。