Cannot find external module 'angular2/angular2' - Angular2 w/ Typescript

前端 未结 10 1474
臣服心动
臣服心动 2020-12-01 21:20

I am going through the step by step tutorial on angular.io (Angular 2). I am using typescript. I get the following error when trying to compile:

Cannot find ex

10条回答
  •  广开言路
    2020-12-01 21:42

    • TypeScript VS2015 project

    CommonJS won't generate the right js code to use inside the quickstart ng2 tutorial code as it stands today (20160215): import {Component} from 'angular2/core';

    Am I right?

    CommonJS will generate this as ES6: var core_1 = require('angular2/core'); ...

    That will not work in the browser and will say that require is not defined as the quickstart uses SystemJS. Code editor will be giving no errors, though, all good there in VS2015.

    SystemJS will generate this as ES6: System.register(['angular2/core'], function(exports_1) { ...

    Works like a charm in the browser but will give that "Cannot find module" error. Don't know how to solve this except using the Empty HTML ASP.NET Web Application -> This one will give you hell to include node_modules inside wwwroot without actually copying it there (at least for a newbie .net programmer).

    Raf.

提交回复
热议问题