简体   繁体   中英

How to get angular2 to working in Visual Studio 2015 with TypeScript?

OS: Windows 10 Pro
IDE: Visual Studio 2015 Community

So I've been trying to get the '5 minute quickstart' demo ( https://angular.io/guide/quickstart ) to work on VS 2015, without success.

I have a package.json file 'included' in my project:

{
  "name": "TypeScriptHTMLApp2",
  "version": "1.0.0",
  "description": "",
  "main": "app.ts",
  "dependencies": {
    "angular2": "2.0.0-alpha.46",
    "systemjs": "0.19.6"
  }
}

and have 'excluded' the 'node_modules' folder, because when included it was generating many duplicate error messages.

But I'm getting error TS2307 'Cannot find module 'angular2/angular2' on the following line:

import {Component, bootstrap} from "angular2/angular2";

How do I resolve this issue so as to make this demo work?

Many thanks in advance

you have to unload your project file and add the below line

 <PropertyGroup Condition="'$(Configuration)' == 'Debug'">
    <TypeScriptRemoveComments>false</TypeScriptRemoveComments>
    <TypeScriptSourceMap>true</TypeScriptSourceMap>
    <TypeScriptTarget>ES5</TypeScriptTarget>
    <TypeScriptJSXEmit>None</TypeScriptJSXEmit>
    <TypeScriptCompileOnSaveEnabled>True</TypeScriptCompileOnSaveEnabled>
    <TypeScriptNoImplicitAny>False</TypeScriptNoImplicitAny>
    <TypeScriptModuleKind>System</TypeScriptModuleKind>
    <TypeScriptModuleResolution>node</TypeScriptModuleResolution> <!-- THIS LINE -->
    <TypeScriptOutFile />
    <TypeScriptOutDir />
    <TypeScriptGeneratesDeclarations>False</TypeScriptGeneratesDeclarations>
    <TypeScriptExperimentalDecorators>true</TypeScriptExperimentalDecorators>
    <TypeScriptNoEmitOnError>True</TypeScriptNoEmitOnError>
    <TypeScriptMapRoot />
    <TypeScriptSourceRoot />
  </PropertyGroup> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM