babel / metalsmith-babel

A Metalsmith plugin to compile JavaScript with Babel

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Object.assign is not a function

ismay opened this issue · comments

commented

When using metalsmith-babel I'm getting the following error:

> stats@0.1.0 watch /Users/ismay/Projects/stats
> node build.js --development

/Users/ismay/Projects/stats/build.js:60
    if (err) throw err;
                   ^
TypeError: Object.assign is not a function
    at metalsmithBabelfileIterator (/Users/ismay/Projects/stats/node_modules/metalsmith-babel/index.js:19:75)
    at Array.forEach (native)
    at Ware.metalsmithBabelPlugin (/Users/ismay/Projects/stats/node_modules/metalsmith-babel/index.js:14:24)
    at Ware.<anonymous> (/Users/ismay/Projects/stats/node_modules/metalsmith/node_modules/ware/node_modules/wrap-fn/index.js:45:19)
    at next (/Users/ismay/Projects/stats/node_modules/metalsmith/node_modules/ware/lib/index.js:85:20)
    at /Users/ismay/Projects/stats/node_modules/metalsmith/node_modules/ware/node_modules/wrap-fn/index.js:121:18
    at done (/Users/ismay/Projects/stats/node_modules/metalsmith-duo/node_modules/async/lib/async.js:132:19)
    at /Users/ismay/Projects/stats/node_modules/metalsmith-duo/node_modules/async/lib/async.js:32:16
    at Duo.<anonymous> (/Users/ismay/Projects/stats/node_modules/metalsmith-duo/lib/index.js:90:9)
    at Immediate._onImmediate (/Users/ismay/Projects/stats/node_modules/metalsmith-duo/node_modules/duo/node_modules/co/index.js:52:14)
    at processImmediate [as _immediateCallback] (timers.js:371:17)

with this build file:

// build.js
/**
 * Dependencies
 */

var argv = require('yargs').argv;
var babel = require('metalsmith-babel');
var duo = require('metalsmith-duo');
var filenames = require('metalsmith-filenames');
var inPlace = require('metalsmith-in-place');
var metalsmith = require('metalsmith');
var rename = require('metalsmith-rename');
var watch = require('metalsmith-watch');
var when = require('metalsmith-if');

/**
 * Init
 */

// Assign command line arguments
var development = argv.development;
var production = !development;

/**
 * Build
 */

metalsmith(__dirname)

  // Process css
  .use(duo({entry: ['css/styles.css']}))

  // Process js
  .use(babel({
    'modules': 'common',
    'comments': true
  }))

  // Process templates
  .use(filenames())
  .use(inPlace({
    cache: false,
    engine: 'swig',
    pattern: '**/*.swig'
  }))
  .use(rename([[/\.swig$/, '.html']]))

  // Watch for changes (when in development mode)
  .use(when(development, watch({
    paths: {
      '${source}/**': true,
      'lib/**/*.css': '**/*.css',
      'lib/**/*.js': '**/*.js',
      'lib/**/*.swig': '**/*.swig'
    }
  })))

  // Build site
  .destination('build')
  .build(function(err){
    if (err) throw err;
  });

I've tried debugging this, but haven't gotten far. Any idea whether I'm doing something wrong, or is this a bug?

Upgrade to the latest stable Node. metalsmith-babel doesn't support Node v0.x. 56b6555

commented

Ah that was it. I was running iojs, but somehow after my update to el capitan it fell back to node 0.12. Thanks!