javascripttypescriptecmascript-6typescript1.6

Can't find module 'hbs' with ES6 style import


I'm doing this in TypeScript, but tried it in vanilla JS as well with the same error. I've pulled down two modules: express and hbs. I'm trying to use the ES6 import syntax like this:

import * as http from 'http';
import * as express from 'express';
import hbs from 'hbs'; 

The last line gives me an error saying it can't find module hbs. I'm looking right at it... I can see it just fine. However when I replace the line with the older CommonJS syntax:

var hbs = require('hbs');

It works fine... what gives? Still on the learning curve with ES6...


Solution

  • I was experiecing a similar problem. The syntax is correct ES6 indeed. Good news is that the problem seems to have been fixed already in the development version of the typescript compiler 0.8: try 'npm install typescript@next -g' and then running the compiler again.