Grunt尝试加载空模块失败

时间:2013-03-21 10:30:11

标签: macos npm gruntjs

我对OSX Lion 10.7.3上的Jenkins设置感到有些困惑。

我在我的webapp中使用Grunt来运行Jasmine测试,构建更少,创建缓存清单等。一切都在我的笔记本电脑Lion 10.7.5上运行,但在服务器上grunt不时失败,出现以下错误:

$ grunt less

module.js:340
    throw err;
          ^
Error: Cannot find module ''
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:362:17)
    at require (module.js:378:17)
    at ChildProcess.<anonymous> (/usr/local/lib/node_modules/grunt-cli/bin/grunt:44:3)
    at ChildProcess.EventEmitter.emit (events.js:99:17)
    at Process._handle.onexit (child_process.js:678:10)

这是间歇性的,它大约在五次运行中失败,并且不是特定于任务的。在运行grunt清单或grunt测试时,它以相同的速率失败。

我注意到的一件事是,当它工作时,它需要一两秒才能完成任务开始执行,但是当它失败时会立即失败。

我尝试删除node_modules,npm cache clear,重新安装grunt-cli。什么都行不通。

这是我的package.json:

{
    "name": "webapp",
    "version": "0.0.0",
    "dependencies": {},
    "devDependencies": {
        "grunt": "0.4.0rc7",
        "grunt-contrib-copy": "0.4.0rc7",
        "grunt-contrib-concat": "0.1.2rc6",
        "grunt-contrib-coffee": "0.4.0rc7",
        "grunt-contrib-uglify": "0.1.1rc6",
        "grunt-contrib-compass": "0.1.1rc8",
        "grunt-contrib-jshint": "0.1.1rc6",
        "grunt-contrib-mincss": "0.4.0rc7",
        "grunt-contrib-connect": "0.1.1rc6",
        "grunt-contrib-clean": "0.4.0rc6",
        "grunt-contrib-htmlmin": "0.1.1rc7",
        "grunt-contrib-imagemin": "0.1.1rc8",
        "grunt-contrib-livereload": "0.1.0rc8",
        "grunt-contrib-jasmine": "~0.3.2",
        "grunt-contrib-less": "0.5.0",
        "grunt-manifest": "0.4.0",
        "grunt-jslint": "0.2.5",
        "grunt-bower-hooks": "~0.2.0",
        "grunt-usemin": "~0.1.7",
        "grunt-regarde": "~0.1.1",
        "grunt-requirejs": "~0.3.1",
        "grunt-mocha": "~0.2.2",
        "grunt-open": "~0.1.0",
        "matchdep": "~0.1.1"
    },
    "engines": {
        "node": ">=0.8.0"
    }
}

npm和节点版本:

$ npm -version
1.2.11
$ node --version
v0.8.20

我现在已经删除了packages.json和Gruntile.js:

$ cat package.json 
{
    "name": "webapp",
    "version": "0.0.0",
    "dependencies": {},
    "devDependencies": {
        "grunt": "0.4.0rc7",
        "grunt-manifest": "0.4.0",
        "matchdep": "~0.1.1"
    },
    "engines": {
        "node": ">=0.8.0"
    }
}
$ cat Gruntfile.js 
'use strict';

module.exports = function (grunt) {
    // load all grunt tasks
    require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

    grunt.initConfig({
        manifest: {
            generate: {
                options: {
                    basePath: 'app/',
                    exclude: ['js/lib/amp/com.vaultus.api.WebApiAggregated.cache.js', 'js/lib/amp/com.vaultus.api.DebugWebApiAggregated.cache.js'],
                    timestamp: true
                },
                src: [
                    'index-hybrid.html',
                    '*.xml',
                    'js/**/*.js',
                    'css/**/*.css',
                    'css/images/**/*',
                    'i18n/**/*.js',
                    'template/**/*.html'
                ],
                dest: 'app/cache-manifest.mf'
            }
        }
    });

    grunt.registerTask('build', [
        'manifest'
    ]);

    grunt.registerTask('default', ['build']);
};

没有运气:(

1 个答案:

答案 0 :(得分:0)

我们在CI版本中遇到了这个问题。

经过一番挖掘,看起来这是grunt-cli 0.1.6中的一个错误和0.1.7 grunt-cli中的has been fixed