Angular 2/Typescript: require not found

By : dejakob

I am trying to get the angular 2 example running with a gulp typescript compiler. The gulp-script compiles

import {Component, View, bootstrap} from 'angular2/angular2';


var angular2_1 = require("angular2/angular2")

which does not run in the browser. What is wrong with this? As far as I know, this kind of implementation of 'require' is only used with nodeJS. Why does the TypeScript compiler still compile it like that?

Anyone any ideas?

Kind regards

By : dejakob


I was not able to get that working but was able to get it working with gulp-traceur. Here is my gulpfile.

var gulp = require('gulp');
var gulpTraceur = require('gulp-traceur');
var through2 = require('through2');
var gutil = require('gulp-util');
var sourcemaps = require('gulp-sourcemaps');
var copy = require('gulp-copy');

gulp.task('compile',function() {
  return gulp.src("./*.es6.js")
        sourceMaps: true,
        outputLanguage: 'es5',
        annotations: true, // parse annotations
        types: true, // parse types
        script: false, // parse as a module
        memberVariables: true, // parse class fields
        modules: 'instantiate'

gulp.task('copy', function () {
    return gulp.src(['*.html', '*.css'])

gulp.task('watch', function () {['*.html', '*.css', './*.es6.js'], ['compile', 'copy']);

gulp.task('default', ['compile', 'copy', 'watch']);

The project can be seen here:

By : unobf

This video can help you solving your question :)
By: admin