【问题标题】:Grunt fails trying to load an empty moduleGrunt 尝试加载空模块失败
【发布时间】:2013-03-10 19:29:56
【问题描述】:

我在 OSX Lion 10.7.3 上的 Jenkins 设置有点卡住了。

我在我的 web 应用程序中使用 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 manifest 或 grunt test 时,它以相同的速率失败。

有一次我注意到,当它工作时,它需要一两秒钟才能开始执行任务,但当它失败时,它会立即失败。

我尝试删除 node_modules、npm 缓存清除、重新安装 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']);
};

运气不好:(

【问题讨论】:

    标签: macos npm gruntjs


    【解决方案1】:

    我们在 CI 构建中遇到了这个问题。

    经过一番挖掘,这似乎是 grunt-cli 0.1.6 和 has been fixed 在 grunt-cli 0.1.7 中的一个错误。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-01-06
      • 2017-04-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多