我正在尝试从一个简单的 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
我错过了什么吗?