GruntをCentOSで使ったらうまくいかなかったのと、無理やり対応
調べてみるとCentOS6あたりの人が困っている感じでGrunt回りでうまくいかないことと対処法
ちなみに「CentOS release 6.4 (Final)」さくらのVPS
インストールの失敗
Grunt回りのものを一式npm installすると、gifsicleのところでエラーが出る
gifsicle-1.71.tar.gz をコンパイルするところっぽい
そこでエラーが出ても止まらない
エラーの内容は変わっていくから無限ループじゃないのかもしれないけどひたすらエラーが出まくるので途中停止
もう一度npm installすると何事もなかったかのようになっている……。
その時はまあいいかと思っていました。
build時のエラー
grunt buildを実行すると、jpg画像の時は問題なかったのですが、pngを追加したらエラーが……。
Warning: /home/www/evm/node_modules/grunt-contrib-compass/node_modules/tmp/lib/tmp.js:261 throw err; ^ Error: spawn ENOENT at errnoException (child_process.js:980:11) at Process.ChildProcess._handle.onexit (child_process.js:771:34) Use --force to continue.
grunt-contrib-compassがだめらしい
でもcompassの実行によるものではなさそう。
動作見てみるとdistのimagesにhogehoge.png.tmpが残ったままだったのでここが怪しいなと。
で、実際は「grunt-contrib-imagemin」を動作させるところでエラーとなっていたらしい
もっと調べると上のインストールエラーも「grunt-contrib-imagemin」だったので、ここでエラーとなったのが原因なんだろうなという感じ
node-gifsicleが入ればすべて解決するという感じでいろいろ探したものの
https://github.com/yeoman/node-gifsicle/issues/11
どうも解決してないか、少なくとも依存で入るgifsicleを昔のバージョンにするとか変える必要がありそう
無能エンジニアとしては変え方とかわかんなーいって感じでパッケージのpackage.jsonの数字だけ触りたいので、
とりあえず古くする「"grunt-contrib-imagemin": "~0.1.4"」
"devDependencies": { "grunt": "~0.4.1", "grunt-contrib-copy": "~0.4.1", "grunt-contrib-concat": "~0.3.0", "grunt-contrib-uglify": "~0.2.0", "grunt-contrib-compass": "~0.6.0", "grunt-contrib-jshint": "~0.6.3", "grunt-contrib-cssmin": "~0.6.0", "grunt-contrib-connect": "~0.5.0", "grunt-contrib-clean": "~0.5.0", "grunt-contrib-htmlmin": "~0.1.3", "grunt-bower-install": "~0.5.0", "grunt-contrib-imagemin": "~0.1.4", "grunt-contrib-watch": "~0.5.2", "grunt-rev": "~0.1.0", "grunt-autoprefixer": "~0.2.0", "grunt-usemin": "~0.1.10", "grunt-mocha": "~0.4.0", "grunt-svgmin": "~0.2.0", "grunt-concurrent": "~0.3.0", "load-grunt-tasks": "~0.1.0", "time-grunt": "~0.1.1", "claymate": "~2.0.3" }
結果:動いた(笑)