咕噜警告:任务“concat”未find
我正在尝试一个简单的Grunt示例,但是我遇到了grunt-contrib-concat的问题 。
这是我的Gruntfile.js:
$ cat Gruntfile.js module.exports = function(grunt) { grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), concat: { options: { separator: ';' }, dist: { src: ['src/**/*.js'], dest: 'dist/<%= pkg.name %>.js' } } }); grunt.loadNpmTasks('grunt-contrib-concat'); grunt.registerTask('default', ['concat']);
和我的package.json:
$ cat package.json { "name": "Linker", "version": "0.0.0", "description": "A test project that is meant to be a dependency", "repository": { "type": "git", "url": "git://github.com/jonbri/Linker.git" }, "main": "src/index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { "grunt-contrib-concat": "*" }, "author": "", "license": "ISC" }
运行npm install不会显示任何明显的错误:
$ npm install $ ls node_modules/ grunt grunt-contrib-concat
这是我的目录结构看起来像:
$ ls Gruntfile.js node_modules package.json README.md src $ ls src index.js
当我运行grunt concat时,我得到这个:
$ grunt concat Loading "concat.js" tasks...ERROR >> Error: Cannot find module 'ansi-styles' Warning: Task "concat" not found. Use --force to continue. Aborted due to warnings.
我的设置:
Lubuntu 12.10,节点:v0.10.25,npm:1.4.21,grunt-cli:v0.1.13,grunt:v0.4.5
我错过了什么吗?
你应该像下面这样运行它: grunt
without concat
因为任务是default
。 运行它不需要参数。 所以启动命令变得简单:
grunt
使用这个来安装grunt-contrib-concat:
npm install grunt-contrib-concat --save-dev
Package.json应该是这样的:
"devDependencies": { "grunt-contrib-concat": "^0.5.1" },