1

I'd like to target ES6 as output. This is for a node server side app that I can run on the bleeding-edge iojs distro, which hopefully supports the latest es6 syntax.

But I'm not clear how to use standard NPM libraries with the new import syntax?

require is now a bad word. I noticed this answer but

import http from "http";
import request from "request";

gives

error TS2307: Cannot find module 'http'

Is there a way to use these standard node libs, or other NPM modules already, without a complex transpile/babel build chain?

Community
  • 1
  • 1
dcsan
  • 11,333
  • 15
  • 77
  • 118

1 Answers1

6

error TS2307: Cannot find module 'http'

You need to include node.d.ts in your compilation context.

Also import http from "http"; is wrong. Should be import * as http from "http"; or import http = require("http");

basarat
  • 261,912
  • 58
  • 460
  • 511