首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >(SystemJS) XHR错误(404)加载SystemJS

(SystemJS) XHR错误(404)加载SystemJS
EN

Stack Overflow用户
提问于 2018-05-15 12:40:18
回答 1查看 495关注 0票数 0

在编译我的应用程序时,我得到了以下错误。直到最近(我这边没有任何变化),它一直运作得很好。我搜索了与RXJS目录更改有关的论坛,并在可能的情况下进行了修复,但每次修复都会得到另一个错误:(。

控制台错误

Systemjs.config.js

代码语言:javascript
复制
(function (global) {
System.config({
    paths: {
        'npm:': 'https://unpkg.com/'            
    },
    map: {
        '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',

        // other libraries
        'rxjs': 'npm:rxjs',         //see------https://github.com/ReactiveX/rxjs/issues/2971
        'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js'
    },
    packages: {
        'app': {
            main: '/Shop/Components/main.js',
            defaultExtension: 'js',
            meta: {
              './*.js': {
                loader: '/scripts/systemjs-angular-loader.js'
              }
            }
        },
        'rxjs': { defaultExtension: 'js' },
        'rxjs/operators': { defaultExtension: 'js' }
    }
});
})(this);

Main.ts

代码语言:javascript
复制
import { platformBrowserDynamic } from "@angular/platform-browser-dynamic";
import { AppModules } from './AppModules.js';

platformBrowserDynamic().bootstrapModule(AppModules)
    .then(success => console.log(`Bootstrap success`))
    .catch(err => console.error(err));

我将我的npm路径指向unpkg.com,因为这更适合我,而不是node_modules,所以对此错误的任何其他建议/修复都将是一个很大的帮助。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-05-16 12:36:32

对于与Systemjs.config.js有类似问题的人来说,答案是将版本号添加到您的角包中。

示例:

代码语言:javascript
复制
'npm:@angular/module@x.x.x/bundles/xxxx.umd.js',

如果有依赖冲突的话,这对我有效。

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

https://stackoverflow.com/questions/50350463

复制
相关文章

相似问题

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