0

I got problems with transpiling es2015 code to to ES5. Problem happens with module imports:

import * as express from "express"

is transpiled to:

var _express = require("express");
var express = _interopRequireWildcard(_express);

Which cause the error:

var app = express();
          ^
TypeError: express is not a function

But if I import with

var express = require('express');

all works fine.

I still want to use es2015 syntax, is there a setting or plugin I should Install in bable to have it work properly ?

Robert Brax
  • 6,508
  • 12
  • 40
  • 69

1 Answers1

0

Use

import express from "express"
Piyush.kapoor
  • 6,715
  • 1
  • 21
  • 21
  • I upgraded to node js 6 which supposedly support all es6 features, and even my own files report 'unexpected' tokens.... why is that ? – Robert Brax Jul 05 '16 at 14:19
  • Node 6 does not support all ES6 features, it does support the vast majority of them though. – loganfsmyth Jul 05 '16 at 15:16