LoginSignup
1
1

More than 5 years have passed since last update.

gulp-uglifyの1.2.0はダメな子

Last updated at Posted at 2015-05-28

gulp-uglifyを使って次のようなタスクを作ってgulp buildを実行すると次のようなエラーが出る。

gulpタスクの定義

gulpfile.js
var gulp = require('gulp');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var react = require('gulp-react');

var path = {
  HTML         : 'src/index.html',
  ALL          : ['src/js/*.js', 'src/js/**/*.js', 'src/index.html'],
  JS           : ['src/js/*.js', 'src/js/**/*.js'],
  MINIFIED_OUT : 'build.min.js',
  DEST_SRC     : 'dist/src',
  DEST_BUILD   : 'dist/build',
  DEST         : 'dist'
}

gulp.task('build', function(){
  gulp.src(path.JS)
    .pipe(react())
    .pipe(concat(path.MINIFIED_OUT))
    .pipe(uglify(path.MINIFIED_OUT))
    .pipe(gulp.dest(path.DEST_BUILD));
});

エラー内容

react-gulp/node_modules/gulp-uglify/node_modules/deap/lib/deap.js:56
                Object.keys(b).forEach(function(p) {
                       ^
TypeError: Object.keys called on non-object
    at Function.keys (native)

ググるとgithubで、

「gulp-uglifyの1.2.0はダメな子だから1.3を使わんね。」
「いやいや、1.3.0どこにあると?1.1.0に落としたらいいちゃないと?」

ってことなんで、おとなしく1.1.0に落とします。

gulp-uglify@1.2.0のアンインストール

消します

npm uninstall gulp-uglify

1.1.0入れます

npm install --save-dev gulp-uglify@1.1.0

タスク再実行

gulp build
[13:38:57] Using gulpfile ~/react-gulp/gulpfile.js
[13:38:57] Starting 'build'...
[13:38:57] Finished 'build' after 14 ms

成功!

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1