咕噜错误:无法找到模块'小球'

时间:2015-04-17 14:29:43

标签: gruntjs

当我运行grunt时,我收到以下错误消息:

Aborted due to warnings.
Marios-MacBook-Air:imageResizer mario$ grunt
Loading "watch.js" tasks...ERROR
>> Error: Cannot find module 'globule'
Warning: Task "watch" not found. Use --force to continue.

奇怪的是,之前运行的grunt正在运行,如果没有对文件进行任何更改,它现在会返回此错误。

有谁知道可能导致此错误的内容以及globule是什么模块?

这是package.json

{
  "name": "imageResizer",
  "version": "1.0.0",
  "description": "Resize images using GraphicsMagick",
  "main": "index.js",
  "scripts": {
    "test": "mocha -R html-cov > coverage.html"
  },
  "author": "Mario Mendes",
  "license": "ISC",
  "dependencies": {
    "aws-sdk": "^2.1.14",
    "gm": "^1.17.0",
    "imagemagick": "^0.1.3",
    "underscore": "^1.8.3"
  },
  "devDependencies": {
    "blanket": "^1.1.6",
    "chai": "^2.1.0",
    "grunt": "^0.4.5",
    "grunt-contrib-watch": "^0.6.1",
    "grunt-execute": "^0.2.2",
    "lodash": "^3.6.0",
    "mocha": "^2.1.0",
    "proxyquire": "^1.3.2"
  }
}

这是我的咕噜文件

var GruntHandler = require("./index.js").GruntHandler;

module.exports = function (grunt) {

    grunt.initConfig({

        pkg: grunt.file.readJSON('package.json'),

        module_target: {
            options: {

                module: true
            },
            files: ['index.js',]
        },

        watch: {
            scripts: {
                files: ['!images/dontdeleteme.png', 'images/*.*']
            }
        }
    });


    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-execute');

    var _800px = {
        width: 800,
        destinationPath: "large"
    };

    var _500px = {
        width: 500,
        destinationPath: "medium"
    };

    var _200px = {
        width: 200,
        destinationPath: "small"
    };

    var _45px = {
        width: 45,
        destinationPath: "thumbnail"
    };

    var _sizesArray = [_800px, _500px, _200px, _45px];

    grunt.event.on('watch', function(action, filepath, target) {
        if (action === "delete") {
            console.log("Deleted image");
        }
        GruntHandler(filepath, _sizesArray);
    });



    grunt.registerTask('default', ['watch']);



    grunt.task.exists('watch');
}

1 个答案:

答案 0 :(得分:2)

似乎你的一些grunt-tasks使用globule模块(参见https://www.npmjs.com/package/globule)但它没有在其依赖项中指定它。实际上grunt API提供了抽象这个库的方法,所以我猜有些库被弃用或过时....

也许您正在运行某个grunt依赖项的旧版本,请尝试在npm install之前执行grunt

最后但并非最不重要:如果这不起作用,请检查您的npm缓存。运行npm cache cleannpm prune来清理您的项目。

祝你好运。