我试着从一个简单的Grunt示例开始,但是我遇到了一个关于咕噜
这是我的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安装不会显示任何明显的错误:
$ 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
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
我是不是遗漏了什么?
发布于 2015-06-22 20:02:45
您应该以以下方式运行它:不带grunt的concat任务是default任务。运行它不需要任何参数。因此,要启动的命令变得简单了:
grunt
用这个安装咕噜
npm install grunt-contrib-concat --save-devPackage.json应该有这样的内容:
"devDependencies": {
"grunt-contrib-concat": "^0.5.1"
}, https://stackoverflow.com/questions/30988252
复制相似问题