> SyntaxError-6ren">
gpt4 book ai didi

css - Grunt watch (gruntjs) 操作给出此错误代码 : EACCES

转载 作者:太空宇宙 更新时间:2023-11-03 18:05:41 24 4
gpt4 key购买 nike

在一个元素文件夹中执行 grunt 操作时,我在一个文件上出现了两个错误,需要更改该文件。请看一下错误结构:

Running "less:dev" (less) task
>> SyntaxError: Unable to write "assets/css/main.css.map" file (Error code: EACCES). in assets/less/main.less on line null, column 0:
>> 1 @import "_bootstrap";
Warning: Error compiling assets/less/main.less Use --force to continue.

Aborted due to warnings.

编辑

添加 Grunt js 文件

'use strict';
module.exports = function(grunt) {
// Load all tasks
require('load-grunt-tasks')(grunt);
// Show elapsed time
require('time-grunt')(grunt);

var jsFileList = [
'assets/vendor/bootstrap/js/transition.js',
'assets/vendor/bootstrap/js/alert.js',
'assets/vendor/bootstrap/js/button.js',
'assets/vendor/bootstrap/js/carousel.js',
'assets/vendor/bootstrap/js/collapse.js',
'assets/vendor/bootstrap/js/dropdown.js',
'assets/vendor/bootstrap/js/modal.js',
'assets/vendor/bootstrap/js/tooltip.js',
'assets/vendor/bootstrap/js/popover.js',
'assets/vendor/bootstrap/js/scrollspy.js',
'assets/vendor/bootstrap/js/tab.js',
'assets/vendor/bootstrap/js/affix.js',
'assets/js/plugins/*.js',
'assets/js/_*.js'
];

grunt.initConfig({
jshint: {
options: {
jshintrc: '.jshintrc'
},
all: [
'Gruntfile.js',
'assets/js/*.js',
'!assets/js/scripts.js',
'!assets/**/*.min.*'
]
},
less: {
dev: {
files: {
'assets/css/main.css': [
'assets/less/main.less'
]
},
options: {
compress: false,
// LESS source map
// To enable, set sourceMap to true and update sourceMapRootpath based on your install
sourceMap: true,
sourceMapFilename: 'assets/css/main.css.map',
sourceMapRootpath: '/app/themes/roots/'
}
},
build: {
files: {
'assets/css/main.min.css': [
'assets/less/main.less'
]
},
options: {
compress: true
}
}
},
concat: {
options: {
separator: ';',
},
dist: {
src: [jsFileList],
dest: 'assets/js/scripts.js',
},
},
uglify: {
dist: {
files: {
'assets/js/scripts.min.js': [jsFileList]
}
}
},
autoprefixer: {
options: {
browsers: ['last 2 versions', 'ie 8', 'ie 9', 'android 2.3', 'android 4', 'opera 12']
},
dev: {
options: {
map: {
prev: 'assets/css/'
}
},
src: 'assets/css/main.css'
},
build: {
src: 'assets/css/main.min.css'
}
},
modernizr: {
build: {
devFile: 'assets/vendor/modernizr/modernizr.js',
outputFile: 'assets/js/vendor/modernizr.min.js',
files: {
'src': [
['assets/js/scripts.min.js'],
['assets/css/main.min.css']
]
},
uglify: true,
parseFiles: true
}
},
version: {
default: {
options: {
format: true,
length: 32,
manifest: 'assets/manifest.json',
querystring: {
style: 'roots_css',
script: 'roots_js'
}
},
files: {
'lib/scripts.php': 'assets/{css,js}/{main,scripts}.min.{css,js}'
}
}
},
watch: {
less: {
files: [
'assets/less/*.less',
'assets/less/**/*.less'
],
tasks: ['less:dev', 'autoprefixer:dev']
},
js: {
files: [
jsFileList,
'<%= jshint.all %>'
],
tasks: ['jshint', 'concat']
},
livereload: {
// Browser live reloading
// https://github.com/gruntjs/grunt-contrib-watch#live-reloading
options: {
livereload: false
},
files: [
'assets/css/main.css',
'assets/js/scripts.js',
'templates/*.php',
'*.php'
]
}
}
});

// Register tasks
grunt.registerTask('default', [
'dev'
]);
grunt.registerTask('dev', [
'jshint',
'less:dev',
'autoprefixer:dev',
'concat'
]);
grunt.registerTask('build', [
'jshint',
'less:build',
'autoprefixer:build',
'uglify',
'modernizr',
'version'
]);
};

感谢您抽出时间,祝您编码愉快!

最佳答案

看起来您的“assets/less/”目录中没有 _bootstrap.less 文件。

有两种方法可以解决这个问题:
1.将bootstrap复制到“assets/less/”文件夹
2. 为 gruntfile.js 添加一些选项,您可以在下面找到一些示例:

less: {
dev: {
options: {
compress: false,
// LESS source map
// To enable, set sourceMap to true and update sourceMapRootpath based on your install
sourceMap: true,
sourceMapFilename: 'assets/css/main.css.map',
sourceMapRootpath: '/app/themes/roots/'

// add path to boostrap files
path : '../../ your path '

}
}
}

关于css - Grunt watch (gruntjs) 操作给出此错误代码 : EACCES,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24723383/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com