我的Windows 10计算机上有这个gulpfile.js(下面)。 在Windows 7上一切都很好。我安装的所有东西都比较早了几个小时。 UAC已禁用,当我在没有管理员权限的情况下启动时,我收到此错误。 使用管理员权限时,浏览器同步将永远启动。 我还安装了Visual Studio
[20:12:47] 'browser-sync' errored after 16 ms
[20:12:47] Error: EPERM, operation not permitted 'D:\$RECYCLE.BIN\S-1-5-21-1035505530-3282241661-3853854261-1002'
at Error (native)
at Object.fs.readdirSync (fs.js:761:18)
at Glob._readdir (D:\projects\xampp\htdocs\sample\node_modules\gulp\node_modules\vinyl-fs\node_modules\glob-watcher\node_modules\gaze\node_modules\globule\node_modules\glob\glob.js:577:20)
at Glob._process (D:\projects\xampp\htdocs\sample\node_modules\gulp\node_modules\vinyl-fs\node_modules\glob-watcher\node_modules\gaze\node_modules\globule\node_modules\glob\glob.js:379:15)
at Glob.<anonymous> (D:\projects\xampp\htdocs\sample\node_modules\gulp\node_modules\vinyl-fs\node_modules\glob-watcher\node_modules\gaze\node_modules\globule\node_modules\glob\glob.js:403:14)
at Array.forEach (native)
at Glob.<anonymous> (D:\projects\xampp\htdocs\sample\node_modules\gulp\node_modules\vinyl-fs\node_modules\glob-watcher\node_modules\gaze\node_modules\globule\node_modules\glob\glob.js:402:9)
at Glob._readdir (D:\projects\xampp\htdocs\sample\node_modules\gulp\node_modules\vinyl-fs\node_modules\glob-watcher\node_modules\gaze\node_modules\globule\node_modules\glob\glob.js:554:32)
at Glob._process (D:\projects\xampp\htdocs\sample\node_modules\gulp\node_modules\vinyl-fs\node_modules\glob-watcher\node_modules\gaze\node_modules\globule\node_modules\glob\glob.js:379:15)
at Glob.<anonymous> (D:\projects\xampp\htdocs\sample\node_modules\gulp\node_modules\vinyl-fs\node_modules\glob-watcher\node_modules\gaze\node_modules\globule\node_modules\glob\glob.js:403:14)
events.js:85
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE
at exports._errnoException (util.js:746:11)
at Server._listen2 (net.js:1156:14)
at listen (net.js:1182:10)
at Server.listen (net.js:1267:5)
at Object.module.exports.startServer [as fn] (D:\projects\xampp\htdocs\sample\node_modules\browser-sync\node_modules\browser-sync-ui\lib\async.js:116:39)
at D:\projects\xampp\htdocs\sample\node_modules\browser-sync\node_modules\browser-sync-ui\lib\UI.js:181:14
at iterate (D:\projects\xampp\htdocs\sample\node_modules\browser-sync\node_modules\async-each-series\index.js:8:5)
at D:\projects\xampp\htdocs\sample\node_modules\browser-sync\node_modules\async-each-series\index.js:16:16
at D:\projects\xampp\htdocs\sample\node_modules\browser-sync\node_modules\browser-sync-ui\lib\UI.js:189:13
at Object.module.exports.setUrlOptions [as fn] (D:\projects\xampp\htdocs\sample\node_modules\browser-sync\node_modules\browser-sync-ui\lib\async.js:72:9)
// Include gulp
var gulp = require('gulp');
// Include Our Plugins
var jshint = require('gulp-jshint');
var sass = require('gulp-sass');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var autoprefixer = require('gulp-autoprefixer');
var minifycss = require('gulp-minify-css');
var browserSync = require('browser-sync').create();
// var plumber = require('gulp-plumber');
// Lint Task
gulp.task('lint', function() {
return gulp.src('js/*.js')
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
// Compile Our Sass
gulp.task('sass', function() {
return gulp.src('scss/*.scss')
.pipe(sass())
.pipe(gulp.dest('css'))
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1'))
.pipe(gulp.dest('css'))
.pipe(rename({suffix: '.min'}))
.pipe(minifycss())
.pipe(gulp.dest('css'))
.pipe(browserSync.stream());
});
// Concatenate & Minify JS
gulp.task('scripts', function() {
return gulp.src('js/*.js')
.pipe(concat('all.js'))
.pipe(gulp.dest('dist'))
.pipe(rename('all.min.js'))
.pipe(uglify())
.pipe(gulp.dest('dist'));
});
// Browser sync
gulp.task('browser-sync', function() {
browserSync.init({
proxy: "adrian.dev"
});
gulp.watch(path+"/*.scss", ['styles']);
gulp.watch(path+'/**/*.scss', ['styles']);
gulp.watch("*.html").on('change', browserSync.reload);
gulp.watch("js/*.js").on('change', browserSync.reload);
});
gulp.task('browser-sync', function() {
browserSync.init({
proxy: "adrian.dev"
});
gulp.watch("scss*.scss", ['sass']);
gulp.watch('/**/*.scss', ['sass']);
gulp.watch("*.html").on('change', browserSync.reload);
gulp.watch("js/*.js").on('change', browserSync.reload);
});
// // Reloading
// gulp.task('js-watch', ['lint'], browserSync.reload);
// Watch Files For Changes
gulp.task('watch', function() {
gulp.watch('js/*.js', ['lint', 'scripts']);
gulp.watch('scss/*.scss', ['sass']);
});
// Default Task
gulp.task('default', ['lint', 'sass', 'scripts', 'browser-sync', 'watch']);