[英]Gulp Error: spawn EACCES
gulpfile.js gulpfile.js
'use strict';
var gulp = require('gulp');
gulp.paths = {
src: 'src',
dist: 'dist',
tmp: '.tmp',
e2e: 'e2e'
};
require('require-dir')('./gulp');
gulp.task('build', ['clean'], function () {
gulp.start('buildapp');
});
gulp/server.js 一饮而尽/ server.js
'use strict';
var gulp = require('gulp');
var paths = gulp.paths;
var util = require('util');
var browserSync = require('browser-sync');
var middleware = require('./proxy');
function browserSyncInit(baseDir, files, browser) {
browser = browser === undefined ? 'default' : browser;
var routes = null;
if(baseDir === paths.src || (util.isArray(baseDir) && baseDir.indexOf(paths.src) !== -1)) {
routes = {
'/bower_components': 'bower_components'
};
}
browserSync.instance = browserSync.init(files, {
startPath: '/',
server: {
baseDir: baseDir,
middleware: middleware,
routes: routes
},
browser: browser
});
}
gulp.task('serve', ['watch'], function () {
browserSyncInit([
paths.tmp + '/serve',
paths.src,
], [
paths.tmp + '/serve/{app,components}/**/*.css',
paths.src + '/{app,components}/**/*.js',
paths.src + 'src/assets/images/**/*',
paths.tmp + '/serve/*.html',
paths.tmp + '/serve/{app,components}/**/*.html',
paths.src + '/{app,components}/**/*.html'
]);
});
gulp.task('serve:dist', ['buildapp'], function () {
browserSyncInit(paths.dist);
});
gulp.task('serve:e2e', ['inject'], function () {
browserSyncInit([paths.tmp + '/serve', paths.src], null, []);
});
gulp.task('serve:e2e-dist', ['buildapp'], function () {
browserSyncInit(paths.dist, null, []);
});
node version : v0.10.25
节点版本 :
v0.10.25
npm version : 1.3.10
npm版本 :
1.3.10
gulp CLI and Local version : 3.9.0
gulp CLI和本地版本 :
3.9.0
OS : Ubuntu 14.04.2 LTS
操作系统 :
Ubuntu 14.04.2 LTS
I also install all node packages correctly and no errors. 我还正确安装了所有节点包,没有错误。 But if I run
gulp serve
但是,如果我运行
gulp serve
I get the Error: spawn EACCES
我得到
Error: spawn EACCES
I clearly uninstalled node , npm , bower , gulp etc. and installed them back already but it doesn't solved the problem. 我清楚地卸载了node , npm , bower , gulp等,并且已经安装好了但是它没有解决问题。
Here's the whole error log when I run gulp serve
: 这是我运行
gulp serve
时的整个错误日志:
[22:15:33] Using gulpfile /media/culaste/Data/Code/sampleapp/source/gulpfile.js
[22:15:33] Starting 'styles'...
[22:15:34] gulp-inject 26 files into app.scss.
[22:15:34] Finished 'styles' after 1.24 s
[22:15:34] Starting 'inject'...
[22:15:34] gulp-inject 1 files into 404.tmpl.html.
[22:15:34] gulp-inject 1 files into 500.tmpl.html.
[22:15:35] gulp-inject 1 files into index.html.
[22:15:35] gulp-inject 105 files into 404.tmpl.html.
[22:15:35] gulp-inject 105 files into 500.tmpl.html.
[22:15:35] gulp-inject 105 files into index.html.
[22:15:35] Finished 'inject' after 668 ms
[22:15:35] Starting 'watch'...
[22:15:36] Finished 'watch' after 1.19 s
[22:15:36] Starting 'serve'...
[22:15:36] Finished 'serve' after 94 ms
[BS] Local URL: http://localhost:3000/
[BS] External URL: http://192.168.8.101:3000/
[BS] Serving files from: .tmp/serve
[BS] Serving files from: src
[BS] Watching files...
events.js:72
throw er; // Unhandled 'error' event
^
Error: spawn EACCES
at errnoException (child_process.js:988:11)
at Process.ChildProcess._handle.onexit (child_process.js:779:34)
The problem was when browserSync tries to open my browser, it throws the error because of permission issue. 问题是当browserSync尝试打开我的浏览器时,由于权限问题,它会抛出错误。 adding
open: false
solves the problem. 添加
open: false
解决问题。
gulp/server.js 一饮而尽/ server.js
browserSync.instance = browserSync.init(files, {
startPath: '/',
open:false,
server: {
baseDir: baseDir,
middleware: middleware,
routes: routes
},
browser: browser
});
I know it's not already necessary to fix the permission issue but I think maybe it would be nice if when you run your development server, it will automatically opens the browser(new tab if browser is already open) for you. 我知道没有必要修复权限问题,但我想如果运行开发服务器时,它会自动打开浏览器(如果浏览器已经打开,则会自动打开新选项卡)。 Any suggestions and/or solutions are greatly appreciated.
非常感谢任何建议和/或解决方案。 Thank you everyone.
谢谢大家。
I was facing same issue while running this on ubuntu although everything was working fine on windows, setting open:false in browsersync initialization resolved the issue. 我在ubuntu上运行时遇到了同样的问题,虽然一切都在windows上工作正常,设置open:false在browsersync初始化时解决了问题。
browserSync.instance = browserSync.init(files, {
startPath: '/',
open:false,
server: {
baseDir: baseDir,
middleware: middleware,
routes: routes
},
browser: browser
});
What folder is your project in? 你的项目在哪个文件夹? I ran into an EACCES error due because I had my app installed under /opt
我遇到了EACCES错误,因为我在/ opt下安装了我的应用程序
Have you tried running the server using the command node server.js ? 您是否尝试使用命令node server.js运行服务器?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.