环境为:Linux 2.6.32-573.12.1.el6.x86_64 x86_64,通过SSH
我的咕unt声略有非标准设置,如下所示:
/home/scoots/public_html/
grunt/
package.json
node_modules/
project1/
Gruntfile.js
project2/
Gruntfile.js
project1/
project2/
当我开始观看grunt并对我的Gruntfile.js进行更改时(这并不常见,但是根据项目的需要仍然可能发生),我得到以下错误:
$ cd ~/public_html/grunt/project1
$ grunt watch
Running "watch" task
Waiting...
Reloading watch config...
Fatal error: EACCES: permission denied, scandir '/home'
处理起来非常简单(只需取消并重新启动咕unt声)-但这需要我注意。有时我可以尝试并继续工作,但是咕unt的手表现在将被锁定。
此外,令人讨厌的是,当我在本地(Windows)计算机上安装grunt并从Node.js命令提示符下运行该代码时,该代码就可以正常工作。
作为参考,这是一个展示此问题的示例Gruntfile.js:
module.exports = function(grunt) {
require('time-grunt')(grunt);
require('jit-grunt')(grunt);
grunt.file.setBase('../');
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
site_dir: {
site: '../tcl/wp-content/themes/twentysixteen-child',
jscache: 'wp-content/themes/twentysixteen-child/js/src',
grunt: 'tcl'
},
watch: {
css: {
files: ['<%= site_dir.site %>/css/sass/*.scss'],
tasks: ['sass', 'postcss'],
options: {
spawn: false
}
},
scripts: {
files: ['<%= site_dir.site %>/js/src/*.js'],
tasks: ['include_file', 'uglify'],
options: {
spawn: false
}
},
configFiles: {
files: ['<%= site_dir.grunt %>/Gruntfile.js'],
options: {
reload: true
}
}
},
sass: {
options: {
style: 'expanded', // compressed in postcss
sourcemap: true,
sourceMapEmbed: true,
precision: 8,
includePaths: ['node_modules/bootstrap-sass/assets/stylesheets']
},
dist: {
files: {
'<%= site_dir.grunt %>/css/layout.css': '<%= site_dir.site %>/css/sass/layout.scss'
}
}
},
postcss: {
options: {
map: {
inline: false,
annotation: '<%= site_dir.grunt %>/css/maps/'
},
processors: [
require('autoprefixer')({
browsers: [
"Android 2.3",
"Android >= 4",
"Chrome >= 20",
"Firefox >= 24",
"Explorer >= 8",
"iOS >= 6",
"Opera >= 12",
"Safari >= 6"
]
}),
require('csswring')()
]
},
dist: {
src: '<%= site_dir.grunt %>/css/layout.css',
dest: '<%= site_dir.site %>/css/layout.min.css'
}
},
include_file: {
js: {
cwd: '<%= site_dir.grunt %>/',
src: [
'../<%= site_dir.site %>/js/src/common.js'
],
dest: '<%= site_dir.grunt %>/js/'
}
},
uglify: {
options: {
compress: {
warnings: true
},
mangle: true,
preserveComments: /(?:^!|@(?:license|preserve|cc_on))/
},
build: {
src: [
'<%= site_dir.grunt %>/<%= site_dir.jscache %>/common.js'
],
dest: '<%= site_dir.site %>/js/common.min.js'
}
}
});
grunt.registerTask('default', ['sass', 'postcss', 'include_file', 'uglify']);
};
还有package.json:
{
"name": "Test",
"version": "0.1.0",
"dependencies": {
"bootstrap-sass": "3.3.7"
},
"devDependencies": {
"autoprefixer": "^6.4.1",
"csswring": "^5.1.0",
"grunt": "^1.0.1",
"grunt-contrib-uglify": "^2.0.0",
"grunt-contrib-watch": "^1.0.0",
"grunt-include-file": "^0.1.3",
"grunt-postcss": "^0.8.0",
"grunt-sass": "^2.0.0",
"jit-grunt": "^0.10.0",
"time-grunt": "^1.4.0"
}
}
编辑:详细/启用调试:
$ grunt -v -d watch
Initializing
Command-line options: --verbose, --debug=1
Reading "Gruntfile.js" Gruntfile...OK
Registering Gruntfile tasks.
Reading package.json...OK
Parsing package.json...OK
Initializing config...OK
Loading "Gruntfile.js" tasks...OK
+ default
Running tasks: watch
Loading "grunt-contrib-watch" plugin
Registering "/home/scoots/public_html/grunt/node_modules/grunt-contrib-watch/tasks" tasks.
Loading "watch.js" tasks...OK
+ watch
Running "watch" task
[D] Task source: /home/scoots/public_html/grunt/node_modules/grunt-contrib-watch/tasks/watch.js
Waiting...
Verifying property watch exists in config...OK
Verifying property watch.css.files exists in config...OK
Verifying property watch.scripts.files exists in config...OK
Verifying property watch.config.files exists in config...OK
Watching ../tcl/wp-content/themes/twentysixteen-child/css/sass/__bookings.scss for changes.
Watching ../tcl/wp-content/themes/twentysixteen-child/css/sass/__variables.scss for changes.
Watching ../tcl/wp-content/themes/twentysixteen-child/css/sass/_bootstrap-custom.scss for changes.
Watching ../tcl/wp-content/themes/twentysixteen-child/css/sass/_contactform7.scss for changes.
Watching ../tcl/wp-content/themes/twentysixteen-child/css/sass/_lightslider.scss for changes.
Watching ../tcl/wp-content/themes/twentysixteen-child/css/sass/_lity.scss for changes.
Watching ../tcl/wp-content/themes/twentysixteen-child/css/sass/_zoom.scss for changes.
Watching ../tcl/wp-content/themes/twentysixteen-child/css/sass/layout.scss for changes.
Watching ../tcl/wp-content/themes/twentysixteen-child/js/src/bootstrap.js for changes.
Watching ../tcl/wp-content/themes/twentysixteen-child/js/src/common.js for changes.
Watching ../tcl/wp-content/themes/twentysixteen-child/js/src/instafeed.js for changes.
Watching ../tcl/wp-content/themes/twentysixteen-child/js/src/lightslider.js for changes.
Watching ../tcl/wp-content/themes/twentysixteen-child/js/src/lity.js for changes.
Watching ../tcl/wp-content/themes/twentysixteen-child/js/src/scrollreveal.min.js for changes.
Watching ../tcl/wp-content/themes/twentysixteen-child/js/src/zoom.js for changes.
Watching tcl/Gruntfile.js for changes.
Watching tcl/css for changes.
Watching tcl/js for changes.
Watching tcl/wp-content for changes.
Clearing require cache for "tcl/Gruntfile.js" file...OK
[[[[I edit the Gruntfile here]]]]
Reloading watch config...
Fatal error: EACCES: permission denied, scandir '/home'
答案 0 :(得分:0)
文件glob中的斜线有时会导致此错误,但咕unt的声音不会引发任何错误。只是无声的失败并带有此警告。
确保您的“文件”配置不会导致此错误,并且此<%= site_dir.site%>模板也不会导致null或空白。
watch: {
css: {
files: ['<%= site_dir.site %>/css/sass/*.scss'],
tasks: ['sass', 'postcss'],
options: {
spawn: false
}
},
scripts: {
files: ['<%= site_dir.site %>/js/src/*.js'],
tasks: ['include_file', 'uglify'],
options: {
spawn: false
}
},
configFiles: {
files: ['<%= site_dir.grunt %>/Gruntfile.js'],
options: {
reload: true
}
}
}