我已经开始了一个新的ASP.NET5/MVC6项目。模块分辨率与angular2/ASP.NET5(无法找到angular2/core)
尝试1我的问题是,当我在tsconfig.json
设置moduleResolution
到classic
如下我收到一个错误:
Cannot find module 'angular2/core'
尝试2如果我改变tsconfig.json
使用node
分辨率,排除node_modules
在tsconfig.js
不起作用,this is a bug?,这是关闭,虽然它似乎仍然是一个问题,并遇到多个错误时,演播室2015钓鱼通过node_modules
文件夹includidi整个树中的每个.d.ts
。有数百个错误,主要在rxjs
。
尝试3如果我完全删除tsconfig.json
,我可以在浏览器中执行应用程序并编译文件,但是可能会出现此错误。
Error: (SystemJS) require is not defined
我不禁想,在Visual Studio 的angular2 /打字稿支持是一塌糊涂,我应该回到角1和MVC5。为了记录,我使用的是打字稿2.0.6,而我的视觉工作室完全是最新的。
Is there a combination of
package.json
andtsconfig.json
that actually works out of the box with 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.";
}
}
谢谢,我已经更新了.net核心,并且获得了大部分应用程序,但需要一段时间才能完成,但这可能会有所帮助。在此期间,我正在留下一些更直接的答案。 – Jim
没问题,欢迎您:) –
嗨,只是想知道es6-shim.d.ts扮演了什么角色。es6-shim似乎是将它们全部挂在一起所需要的。在整个node_modules目录中,我会在.d.ts文件中发现大量错误,直到es6-shim.d.ts放置在wwwroot的某处。 tsconfig.json的目标是es5,那么为什么垫片是必要的? – Jim