【发布时间】:2016-08-04 06:18:31
【问题描述】:
我在我们的私人服务器中使用 perforce 进行代码签入,因此在生产构建之后(即,当 index.html 为只读时)我的 gulp 任务失败并出现以下错误。
[INFO] [11:30:19] Error: EPERM: operation not permitted, open 'C:\MyProjectDir\index.html'
一旦我签出文件或取消选中只读属性(使用 windows 框),gulp 任务就会成功完成。有没有办法通过 gulp 任务更改它的权限以避免这种手动干预?
PS:我用过chmod(777)
Gulp 文件(注入发生的结束部分)
var gulp = require('gulp'),
gutil = require('gulp-util'),
uglify = require('gulp-uglify'),
minify = require('gulp-minify-css'),
concatVendor = require('gulp-concat-vendor'),
concatCss = require('gulp-concat-css'),
rev = require('gulp-rev'),
clone = require('gulp-clone'),
inject = require('gulp-inject'),
del = require('del'),
runSequence = require('run-sequence'),
chmod = require('gulp-chmod'),
series = require('stream-series'),
ngAnnotate = require('gulp-ng-annotate'),
rename = require("gulp-rename");
...
gulp.task('index', ['gulp-js-files', 'gulp-css-files'], function() {
var target = gulp.src(mainIndexFile);
return target.pipe(chmod(777)).pipe(inject(series(vendorCss, customCss, vendorJs), { ignorePath: ['MyProjectDir'], addRootSlash: false }))
.pipe(gulp.dest(mainDestination));
});
...
以管理员模式运行 cmd
【问题讨论】:
-
你怎么能在
Windows上做chmod(777)? -
@xAqweRx:它是一个 nodejs 模块,在文档中没有提到它不能在 Windows 上使用,而是说“可以在任何地方使用”npmjs.com/package/chmod
-
抱歉,误解了
chmod。只是一个想法-您是否尝试过以administrativewrights 开始您的cmd? -
@xAqweRx:是的,我以管理员权限开始
cmd -
是打算改变JS文件的路径吗?
标签: javascript html gulp