【问题标题】:How to get angular2 to working in Visual Studio 2015 with TypeScript?如何让 angular2 使用 TypeScript 在 Visual Studio 2015 中工作?
【发布时间】:2017-10-03 07:15:16
【问题描述】:

操作系统:Windows 10 专业版
IDE:Visual Studio 2015 社区

所以我一直在尝试让“5 分钟快速入门”演示 (https://angular.io/guide/quickstart) 在 VS 2015 上运行,但没有成功。

我的项目中“包含”了一个 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 'Cannot find module 'angular2/angular2':

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

如何解决此问题以使此演示正常运行?

在此先感谢

【问题讨论】:

标签: typescript visual-studio-2015 angular


【解决方案1】:

您必须卸载您的项目文件并添加以下行

 <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> 

【讨论】:

    猜你喜欢
    • 2017-04-28
    • 1970-01-01
    • 2016-02-05
    • 2017-01-06
    • 2013-08-07
    • 2017-08-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多