首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用angular2 / ASP.NET5解析模块(找不到angular2/core)

用angular2 / ASP.NET5解析模块(找不到angular2/core)
EN

Stack Overflow用户
提问于 2016-11-10 06:21:42
回答 1查看 294关注 0票数 0

我已经启动了一个新的ASP.NET 5/MVC6项目。

尝试1我的问题是当我在tsconfig.json中将moduleResolution设置为classic时,我收到一个错误,如下所示:

找不到模块‘angular2 2/core’

尝试2如果我将tsconfig.json更改为使用node解析,则tsconfig.js中的排除node_modules不起作用,这是个窃听器?已经关闭,尽管它似乎仍然是一个问题,而且当studio 2015在node_modules文件夹中进行操作时遇到多个错误,包括整个树中的每个.d.ts。有数百个错误,主要是在rxjs中。

尝试3,如果我完全删除tsconfig.json,我可以让应用程序执行,文件被编译,但是唉,浏览器中的这个错误。

错误:(SystemJS)要求未定义

我情不自禁地认为Visual 中的/类型记录支持是一个完全混乱的__,我应该回到角度1和MVC5。作为记录,我使用的是类型记录2.0.6,我的视觉工作室完全是最新的。

是否有package.jsontsconfig.json的组合与VisualStudio2015forangular2一起实际开箱即用。

package.json有以下依赖项。

代码语言:javascript
复制
{
  "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如下所示

代码语言:javascript
复制
{
  "compilerOptions": {
    "experimentalDecorators": true,
    "moduleResolution": "classic"
  },
  "exclude": ["node_modules"]
}

boot.ts如下所示

代码语言:javascript
复制
/// <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

代码语言:javascript
复制
/// <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.";
    }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-11-10 07:00:20

es6-shim.d.ts NB:确保安装在根目录中。许多由类型记录遍历的node_modules文件在没有es6-shim.d.ts的情况下无法编译。

我有一个集成angular2(2.1.0)和ASP.NET核心的示例,我认为NG2的包依赖关系也将适用于ASP.NET5。

package.json

systemjs.config.js

希望能帮上忙!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40521115

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档