1
我想第一次使用Grunt。我认为我正确地按照指示安装和使用Grunt插件(grunt-text-replace)。 (例如,请参见Grunt's page和the plugin's。)但是,我无法成功运行任何内容 - 相反,我仍然收到相同的错误。我一直在根据Grunt和插件的指示来检查我的代码,但是我看不到任何错误。Grunt警告:没有找到源文件
这里是我的package.json文件:
{
"name": "brink-prototype",
"version": "0.0.0",
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-jshint": "~0.1.1",
"grunt-contrib-nodeunit": "~0.1.2",
"grunt-text-replace": "~0.3.2"
}
}
这里是我的Gruntfile.js:
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
replace: {
src: ['components/bootstrap/less/navbar.less'],
dest: 'build/',
replacements: [{
from: /\.box-shadow.*$/g,
to: ''
}]
}
});
grunt.loadNpmTasks('grunt-text-replace');
grunt.registerTask('default', ['replace']);
};
当我运行在命令行中 “咕噜”,我得到以下错误:
Running "replace:src" (replace) task
Warning: No source files found Use --force to continue.
Aborted due to warnings.
我也试过这个过程中与其他插件(咕噜正则表达式替换),并有完全相同的错误消息。
我哪里出错了?
UPDATE:
以下是文件结构的相关部分:
- 项目/
- Gruntfile.js
- 的package.json
- 组件/
- bootstrap/
- 更少/
- navbar.less
- 更少/
- bootstrap/
- node_modules/
- 咕噜/
- 咕噜文本替换/
我一直在尝试从Gruntfile.js所在的项目/目录运行命令。
也许我的src
的路径应该是相对于别的吗?我不知道。
该错误意味着grunt无法找到您指定的源文件,它们应该是。你确定该文件存在att'components/bootstrap/less/navbar.less'相对于gruntfile吗?你可以用你的文件结构更新你的问题吗? – 2013-04-23 07:41:36
以上更新。我曾认为路径可能是问题,但无法弄清楚它有什么问题。 – davidtheclark 2013-04-23 13:52:00
这似乎是正确的。但我只注意到它说“找不到源文件”,而不是“源文件未找到”的......这可能是因为你有你*有*把它写像'替换:{子任务:{源:... }}'在文档中的示例中? – 2013-04-23 14:00:23