title: Babel NodeJS ES6: SyntaxError: Unexpected token export
body: <p>I'm trying to use babel to run my NodeJS program, which includes ES6 syntax and exports from the Colyseus library. However, when I run the command:</p>
  
  <pre><code>babel-node server.js
  </code></pre>
  
  <p>The following error message appears:</p>
  
  <pre><code>export class MyRoom extends colyseus.Room {
  ^^^^^^
  
  SyntaxError: Unexpected token export
  </code></pre>
  
  <p>Below is my package.json file:</p>
  
  <pre><code>{
    "name": "app",
    "version": "1.0.0",
    "description": "a description",
    "main": "server.js",
    "scripts": {
      "test": "babel-node server.js",
      "build": "babel-node server.js"
    },
    "author": "henryzhu",
    "license": "ISC",
    "dependencies": {
      "actionhero": "^19.1.2",
      "colyseus": "^0.9.33",
      "easytimer.js": "^2.3.0",
      "express": "^4.16.3",
      "socket.io": "^2.1.0",
      "socketio": "^1.0.0",
      "uniqid": "^5.0.3"
    },
    "devDependencies": {
      "babel-cli": "^6.26.0",
      "babel-preset-env": "^1.7.0",
      "babel-preset-es2015": "^6.24.1"
    }
  }
  </code></pre>
  
  <p>Below is my server.js file:</p>
  
  <pre><code>var colyseus = require("colyseus");
  var http = require("http");
  var express = require("express");
  var port = process.env.port || 3000;
  
  var app = express();
  
  app.use(express.static("public", { dotfiles: 'allow' }));
  
  var gameServer = new colyseus.Server({
    server: http.createServer(app)
  });
  
  export class MyRoom extends colyseus.Room {
      // When room is initialized
      onInit (options) { }
  
  }
  
  gameServer.listen(port);
  </code></pre>