【发布时间】:2016-11-10 06:21:42
【问题描述】:
我已经开始了一个新的 ASP.NET5/MVC6 项目。
尝试1我的问题是,当我在tsconfig.json 中将moduleResolution 设置为classic 时,我收到如下错误:
找不到模块“angular2/core”
尝试 2 如果我将tsconfig.json 更改为使用node 分辨率,则tsconfig.js 中的排除node_modules 不起作用,this is a bug? 已关闭,尽管它似乎仍然存在成为一个问题,当 studio 2015 遍历 node_modules 文件夹(包括整个树中的每个 .d.ts)时,会遇到多个错误。有数百个错误,主要在rxjs。
尝试 3 如果我完全删除 tsconfig.json,我可以执行应用程序并编译文件,但可惜的是,浏览器中出现此错误。
错误:(SystemJS) 要求未定义
我不禁认为 Visual Studio 中的 angular2 / typescript 支持一团糟,我应该回到 angular 1 和 MVC5。作为记录,我使用的是 typescript 2.0.6,我的 Visual Studio 完全是最新的。
是否有
package.json和tsconfig.json的组合在 Visual Studio 2015 for angular2 中开箱即用。
package.json 具有以下依赖关系。
{
"version": "1.0.0",
"name": "asp.net",
"private": true,
"devDependencies": {
"angular2": "^2.0.0-beta.17"
},
"dependencies": {
"@types/angular2": "0.0.2",
"angular2": "^2.0.0-beta.17",
"es6-shim": "^0.35.1",
"gulp": "^3.9.1",
"gulp-jasmine": "^2.4.2",
"gulp-print": "^2.0.1",
"gulp-sass": "^2.3.2",
"gulp-typings": "^2.0.4",
"gulp-watch": "^4.3.10",
"karma": "^1.3.0",
"reflect-metadata": "^0.1.8",
"rxjs": "^5.0.0-rc.2",
"zone.js": "^0.6.26"
}
}
tsconfig.json如下
{
"compilerOptions": {
"experimentalDecorators": true,
"moduleResolution": "classic"
},
"exclude": ["node_modules"]
}
boot.ts如下
/// <reference path="../node_modules/angular2/core.d.ts"/>
// the above is a correct path, but it doesn't seem to matter.
import {bootstrap} from "angular2/platform/browser";
// ~~~~~~~~~~~~~~~~~~~~~~~~~ (Error Here)
import {HTTP_PROVIDERS} from "angular2/http";
import {AppComponent} from "./app.component";
bootstrap(AppComponent, [HTTP_PROVIDERS]);
console.log("starting angular...");
app.component.js
/// <reference path="../node_modules/angular2/core.d.ts"/>
import { Component, OnInit } from "angular2/core";
// ~~~~~~~~~~~~~ (Error Here)
@Component({
selector: "app",
templateUrl: "static.html"
})
export class AppComponent implements OnInit {
message: string;
constructor() {
console.log("starting app component");
}
ngOnInit() {
this
.message =
"The 'static.html' was used as the Angular2 'templateUrl'. There is a 'message' property bound to the <blockqoute> element.";
}
}
【问题讨论】:
标签: angular typescript