0

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)

これは断続的で、5 回の実行に約 1 回失敗し、特定のタスクではありません。grunt manifest または grunt test を実行すると、同じ割合で失敗します。

私が気付いたのは、機能するとタスクの実行が開始されるまでに1〜2秒かかることですが、失敗するとすぐに失敗することです。

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']);
};

運が悪い:(

4

1 に答える 1

0

CI ビルドでこの問題が発生していました。

少し掘り下げた後、これは grunt-cli 0.1.6 のバグであり、0.1.7 の grunt-cli で修正されたようです。

于 2013-04-19T09:31:12.833 に答える