Javascript 运行时未加载类型脚本
我有一个web应用程序,它是在VS2015中使用Angular 2启动的,并且一直在为它工作。我将其升级到VS2017,并进行了一些更改,但总体上看起来一切正常。我没有收到任何编译时错误。在运行阶段,当我试图加载一个页面时,该页面不会完全呈现,并且在屏幕上也不会出现任何真正的错误。我正在使用I.E.11,当我查看控制台时,我得到以下错误:Javascript 运行时未加载类型脚本,javascript,angular,Javascript,Angular,我有一个web应用程序,它是在VS2015中使用Angular 2启动的,并且一直在为它工作。我将其升级到VS2017,并进行了一些更改,但总体上看起来一切正常。我没有收到任何编译时错误。在运行阶段,当我试图加载一个页面时,该页面不会完全呈现,并且在屏幕上也不会出现任何真正的错误。我正在使用I.E.11,当我查看控制台时,我得到以下错误: 错误:语法错误 评价http://localhost:42413/app/app.module.js 评价http://localhost:42413/app
错误:语法错误
评价http://localhost:42413/app/app.module.js
评价http://localhost:42413/app/main.js
正在加载应用程序
有问题的两个文件位于预期的位置,自从我创建端口以来,这些文件周围的代码没有发生任何更改
在main.ts文件中,我有:
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app.module';
platformBrowserDynamic().bootstrapModule(AppModule);
在app.module.js中,我有:
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { HttpModule } from '@angular/http';
import { FormsModule } from '@angular/forms';
import { AppComponent } from './app.component';
import { AgentDetailsComponent } from './recruiter/agent-details.component';
@NgModule({
imports: [
BrowserModule,
HttpModule,
FormsModule
],
declarations: [
AppComponent,
AgentDetailsComponent
],
bootstrap: [AppComponent]
})
export class AppModule { }
错误发生在main.ts的第二行:import{AppModule}from./app.module'
设置断点,但无法到达此文件的第一行。步进JS文件。它首先遍历register-loader.js文件,该文件调用evaluate.js。然后,它在评估方法中失败。有一个巨大的stacktrace,但基本上它在node_模块下的文件中出错
如果我在chrome浏览器中运行,我会收到zone.js发出的一个错误,说明它无法加载
在my projects wwwroot目录中,此组件位于my app\recruiter文件夹中
在app.module.ts文件夹中,它被引用为:
从“./recruiter/agent details.component”导入{AgentDetailsComponent}
悬停在./recruiter/agent-details.component上方的一行在工具提示中显示了正确的路径
在Chrome本身中,执行platformBrowserDynamic().bootstrapModule(AppModule)时似乎会发生错误代码>在main.ts中声明
我的agent-details.component.ts文件具有:
import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { ICountry } from '../services/interfaces/country';
import { RecruiterService } from '../services/recruiter/recruiter.service';
@Component({
selector: 'agent-details',
templateUrl: 'agent-details.component.html',
providers : [RecruiterService]
})
export class AgentDetailsComponent implements OnInit {
private countries: ICountry[] = [];
private errorMessage: string;
constructor(private recruiterService : RecruiterService) {
}
getCountries() {
this.recruiterService.getCountries().subscribe((countries: ICountry[]) => this.countries = countries);
}
ngOnInit(): void {
this.getCountries();
}
}
我认为在您尝试加载html时,将typescript转换为js还没有准备好。因此该文件不可用。我不使用vs,因此我无法提供更多帮助。但也许它可以帮助你找出问题所在,它在其他浏览器中工作吗?还没有在其他浏览器中尝试过,但在我从VS2015改为VS2017@mtizziani我设法进一步跟踪了这个错误。不知道我的更新是否会提供更多的想法。@n00dl3我安装了chrome,它似乎给出了一个路径错误,但为什么我不确定。自升级以来,这些都没有更改。这就好像Zone忽略了我的默认路径。我认为,在您尝试加载html的那一刻,将typescript转换为js还没有准备好。因此该文件不可用。我不使用vs,因此我无法提供更多帮助。但也许它可以帮助你找出问题所在,它在其他浏览器中工作吗?还没有在其他浏览器中尝试过,但在我从VS2015改为VS2017@mtizziani我设法进一步跟踪了这个错误。不知道我的更新是否会提供更多的想法。@n00dl3我安装了chrome,它似乎给出了一个路径错误,但为什么我不确定。自升级以来,这些都没有更改。这就好像Zone忽略了我的默认路径。