当前位置: 首页 > 知识库问答 >
问题:

加载http://localhost:3000/traceur时出现XHR错误(未找到404)

洪弘壮
2023-03-14

    zone.js:101 GET http://localhost:3000/traceur 404 (Not Found)scheduleTask @ zone.js:101ZoneDelegate.scheduleTask @ zone.js:345Zone.scheduleMacroTask @ zone.js:282(anonymous function) @ zone.js:122send @ VM437:3fetchTextFromURL @ system.src.js:1156(anonymous function) @ system.src.js:1739ZoneAwarePromise @ zone.js:607(anonymous function) @ system.src.js:1738(anonymous function) @ system.src.js:2764(anonymous function) @ system.src.js:3338(anonymous function) @ system.src.js:3605(anonymous function) @ system.src.js:3990(anonymous function) @ system.src.js:4453(anonymous function) @ system.src.js:4705(anonymous function) @ system.src.js:408ZoneDelegate.invoke @ zone.js:332Zone.run @ zone.js:225(anonymous function) @ zone.js:591ZoneDelegate.invokeTask @ zone.js:365Zone.runTask @ zone.js:265drainMicroTaskQueue @ zone.js:497ZoneTask.invoke @ zone.js:437
    login:15 Error: Error: XHR error (404 Not Found) loading http://localhost:3000/traceur
    at XMLHttpRequest.wrapFn [as _onreadystatechange] (http://localhost:3000/node_modules/zone.js/dist/zone.js:794:30)
    at ZoneDelegate.invokeTask (http://localhost:3000/node_modules/zone.js/dist/zone.js:365:38)
    at Zone.runTask (http://localhost:3000/node_modules/zone.js/dist/zone.js:265:48)
    at XMLHttpRequest.ZoneTask.invoke (http://localhost:3000/node_modules/zone.js/dist/zone.js:433:34)
    Error loading http://localhost:3000/traceur
    Error loading http://localhost:3000/node_modules/@angular2-material/button/button.js as "@angular2-material/button" from http://localhost:3000/app/assets/js/app.module.js(anonymous function) @ login:15ZoneDelegate.invoke @ zone.js:332Zone.run @ zone.js:225(anonymous function) @ zone.js:591ZoneDelegate.invokeTask @ zone.js:365Zone.runTask @ zone.js:265drainMicroTaskQueue @ zone.js:497ZoneTask.invoke @ zone.js:437


    import { Component, ViewEncapsulation } from '@angular/core';
    import { MdButton } from '@angular2-material/button';
    @Component({
    selector: 'myApp',
    templateUrl: './app/app.html',
    styleUrls: ['./app/app.css'],
    encapsulation: ViewEncapsulation.None
    })
    export class AppComponent {
    }


    import { NgModule } from '@angular/core';
    import { BrowserModule } from '@angular/platform-browser';
    import { FormsModule }   from '@angular/forms';
    import { HttpModule }    from '@angular/http';
    import { MdButtonModule } from '@angular2-material/button';
    import { routing, appRoutingProviders } from './app.routing';
    import { AppComponent } from './app.component';
    import { LoginModule } from './login/login.module';
    import { HomeModule } from './home/home.module';
    import { ItemsModule } from './items/items.module';
    import { MoviesModule } from './movies/movies.module';
    @NgModule({
    imports: [ BrowserModule, FormsModule, HttpModule, MdButtonModule, routing, LoginModule, HomeModule, ItemsModule, MoviesModule ],
    declarations: [ AppComponent ],
    providers: [ appRoutingProviders ],
    bootstrap: [ AppComponent ],
    })
    export class AppModule {}


    import { ModuleWithProviders } from '@angular/core';
    import { Routes, RouterModule } from '@angular/router';
    const appRoutes: Routes = [];
    export const appRoutingProviders: any[] = [];
    export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes);


    import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
    import { AppModule } from './app.module';
    const platform = platformBrowserDynamic();
    platform.bootstrapModule(AppModule);

system.config.js:


    /**
    * System configuration for Angular 2 samples
    * Adjust as necessary for your application needs.
    */
    (function (global) {
    System.config({
    paths: {
    // paths serve as alias
    'npm:': 'node_modules/'
    },
    // map tells the System loader where to look for things
    map: {
    // our app is within the app folder
    app: 'app',
    // angular bundles
    '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
    '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
    '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
    '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
    '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
    '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
    '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
    '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
    '@angular2-material': 'npm:@angular2-material',
    // other libraries
    'rxjs':                       'npm:rxjs',
    'angular2-in-memory-web-api': 'npm:angular2-in-memory-web-api',
    },
    // packages tells the System loader how to load when no filename and/or no extension
    packages: {
    app: {
    main: './main.js',
    defaultExtension: 'js'
    },
    rxjs: {
    main: 'main.js',
    defaultExtension: 'js'
    },
    'angular2-in-memory-web-api': {
    main: './index.js',
    defaultExtension: 'js'
    },
    '@angular2-material/core': {
    main: 'core.js',
    defaultExtension: 'js'
    },     
    '@angular2-material/button': {
    main: 'button.js',
    defaultExtension: 'js'
    },      
    '@angular2-material/card': {
    main: 'card.js',
    defaultExtension: 'js'
    }
    }
    });
    })(this);

当我在“app.module.ts”的imports列表中添加MDButtonModule时,就会出现错误。

共有1个答案

宇文金鑫
2023-03-14

更新2.0.0-Alpha.9 cobalt-kraken(2016-09-26)

角材料已从@Angular2-Material/...@Angular/Material下的包到单个包

因此您的配置可能如下所示:

(function (global) {
  System.config({
    paths: {
      // paths serve as alias
      'npm:': 'node_modules/'
    },
    // map tells the System loader where to look for things
    map: {
      // our app is within the app folder
      app: 'app',
      // angular bundles
      '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
      '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
      '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
      '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
      '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
      '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
      '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
      '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',

      '@angular/material': 'npm:@angular/material/bundles/material.umd.js', <== this line

       ...
    },
    ...
  });
})(this);
import { MaterialModule } from '@angular/material';
@NgModule({
  imports:      [ BrowserModule, MaterialModule ],
  declarations: [ AppComponent ],
  bootstrap:    [ AppComponent ]
})
export class AppModule { }
materialPackages.forEach(name => {
  packages[`@angular2-material/${name}`] = {
    format: 'cjs',
    main: `${name}.umd.js`
  };
});
    null

全部:我们已经更新了我们的包装,以匹配角/角的包装。如果您在项目中使用SystemJS,您可能希望切换到使用我们的UMD包

所以你必须改变你的

system.config.js

packages: {
  ...
  '@angular2-material/core': {
    format: 'cjs',
    main: 'core.umd.js'
  },     
  '@angular2-material/button': {
    format: 'cjs',
    main: 'button.umd.js'
  },      
  '@angular2-material/card': {
    format: 'cjs',
    main: 'card.umd.js'
  },
  ...
 类似资料:
  • 我使用角cli为我的Angular2应用程序。每当我尝试加载angular2/超文本传输协议在我的组件/服务没有错误显示在cli终端,但在我的浏览器的控制台它显示这- 收到http://localhost:4200/angular2/http404(未找到) 未处理的promise拒绝:错误:XHR错误(未找到404)加载http://localhost:4200/angular2/http在XM

  • 我得到下面的错误。我最近将更新为其最新版本,之后出现此错误。我不确定到底出了什么问题,我在谷歌上非常努力地寻找答案,因为我是一个新的角度类型的编程。 我尝试了以下步骤: 已尝试弃用返回,但运气不佳 尝试导入软件包,仍然没有成功 已尝试启动rc1,但运气不佳 你能告诉我实际的问题是什么,我应该如何解决这个问题? localhost/: 38错误:(SystemJS)XHR错误(404未找到)加载ht

  • 我怎么解决这个问题? http://localhost:3000/favicon.ico404(未找到) 服务器有此错误消息: 找不到404错误:在D:\nodetour\app中找不到。第二层的js:82:13。句柄[作为句柄\u请求](D:\nodetour\node\u modules\express\lib\router\layer.js:95:5)位于trim\u前缀(D:\nodeto

  • 问题内容: 我正在尝试将数据流式传输到浏览器。但是,我正在努力将其连接到浏览器。这是我的html: 这是我的app.js的相关部分: 我通过packages.json文件安装了socket.io 0.9.16: 有谁可以帮我离开这里吗?为什么找不到文件? 深入挖掘。为了测试套接字,我将其放在app.js中: 我得到错误: 问题答案: 你可以尝试一下: 我想,您将不得不实例化socket.io服务器

  • 我正在使用http代理中间件将表单数据从React前端发送到Express server, 但是似乎不起作用 它应该代理 而是抛出一个错误: 邮递http://localhost:3000/api/sendMail404(未找到)。 前端代码: 设置代理。js: 服务器js:

  • 我有一个关于react和nodejs的项目。现在,我在localhost:4000(我的服务器)中对用户进行身份验证,然后重定向到localhost:3000/* 但是重新运行这个错误 访问位于“”的XMLHttpRequesthttp://localhost:3000/login“(已从中重定向”http://localhost:4000/login“)起源”http://localhost:3