首页 > 解决方案 > 角度问题 - 无法获取 /

问题描述

我在 Visual Studio 2017 中运行一个ASP.NET Core应用程序Angular。不幸的是,每当我运行该项目时,它都会在浏览器中显示以下消息:

Cannot GET /

经过几个小时的谷歌搜索(示例链接),我尝试了以下操作,并在 tsconfig.json 文件中添加:

"lib": [ "es5", "es6", "es2017", "dom" ]

在我的情况下,这是早些时候如下:

"lib": [ "es2017" ]

虽然项目构建成功,但它几乎没有错误如下:

Severity    Code    Description Project File    Line    Suppression State
Error   TS2583  (TS) Cannot find name 'Set'. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later.  ASP.NETCoreWithAngular  C:\Users\Amit's-PC\source\repos\ASP.NETCoreWithAngular\ASP.NETCoreWithAngular\ClientApp\node_modules\@angular\common\src\directives\ng_class.d.ts   48  Active

Severity    Code    Description Project File    Line    Suppression State
Error   TS2583  (TS) Cannot find name 'Map'. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later.  ASP.NETCoreWithAngular  C:\Users\Amit's-PC\source\repos\ASP.NETCoreWithAngular\ASP.NETCoreWithAngular\ClientApp\node_modules\@angular\core\src\change_detection\differs\default_keyvalue_differ.d.ts    24  Active

Severity    Code    Description Project File    Line    Suppression State
Error   TS2585  (TS) 'Promise' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later.  ASP.NETCoreWithAngular  C:\Users\Amit's-PC\source\repos\ASP.NETCoreWithAngular\ASP.NETCoreWithAngular\ClientApp\node_modules\rxjs\Observable.d.ts   58  Active

我在这里错过了什么?任何想法将不胜感激。

标签: asp.netangularasp.net-core

解决方案


从您收到的错误消息看来,您的默认配置很可能JavaScript是 ises5或以下任何其他配置es2015。这意味着您正在尝试使用es2015功能,而您的编译器现在允许您使用。检查您的 IDE 配置并确保您的JavaScript配置设置为至少es2015


推荐阅读