2015-11-28 106 views
1

操作系統:Windows 10 Pro的
IDE:Visual Studio的2015年社區如何讓angular2在使用TypeScript的Visual Studio 2015中工作?

所以我一直試圖讓 '5分鐘快速入門' 演示(https://angular.io/guide/quickstart)到2015年VS工作,但沒有成功。

我有我的項目的package.json文件「包含」:

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

,並具有「排除」的「node_modules」文件夾,因爲包括當它產生很多重複的錯誤消息。

但我發現了錯誤TS2307「找不到模塊‘angular2/angular2’上以下行:

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

請問該如何解決這個問題,使這個演示的工作?

提前

+1

非常感謝閱讀這篇[評論](https://github.com/angular/angular/issues/ 5248#issuecomment-156043263),它可能會有幫助(閱讀整個問題,這很有趣)。 –

+1

我發現我的問題的解決方案,在這裏:http://stackoverflow.com/a/33183829/5613904 – TheoG

回答

0

你必須卸載你的項目文件,並添加下面一行

<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> 
相關問題