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