首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Grunt尝试加载空模块失败

Grunt尝试加载空模块失败
EN

Stack Overflow用户
提问于 2013-03-21 18:30:11
回答 1查看 1.7K关注 0票数 0

我被OSX Lion 10.7.3上的Jenkins设置卡住了。

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

代码语言:javascript
复制
$ 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缓存,重新安装grunt-cli。毫无办法。

这是我的package.json:

代码语言:javascript
复制
{
    "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和node版本:

代码语言:javascript
复制
$ npm -version
1.2.11
$ node --version
v0.8.20

我现在已经剥离了packages.json和Gruntile.js:

代码语言:javascript
复制
$ 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']);
};

不走运:(

EN

回答 1

Stack Overflow用户

发布于 2013-04-19 17:31:13

我们在CI版本中解决了这个问题。

经过一些挖掘,看起来这是grunt-cli 0.1.6中的一个bug,grunt-cli的0.1.7中的has been fixed

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15544978

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档