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

Angular2 Rc4到Rc5迁移:无法加载网站(traceur/forms)

常智勇
2023-03-14

我今天使用它将我的ng2应用程序从RC4升级到RC5,稍后将从RC5升级到C7。我收到了烦人的错误

http://localhost:5001/ember-cli实时重新加载。js加载资源失败:服务器响应状态为404(未找到)http://localhost:5001/traceur加载资源失败:服务器以404(未找到)区域的状态响应。js:344未处理的promise拒绝:(SystemJS)XHR错误(404未找到)加载http://localhost:5001/traceur错误:XHR错误(404未找到)正在加载http://localhost:5001/traceur在XMLHttpRequest中。wrapFn[as_onreadystatechange](http://localhost:5001/vendor/zone.js/dist/zone.js:636:29)在分区公使馆。调用任务(http://localhost:5001/vendor/zone.js/dist/zone.js:225:37)在这个区域。运行任务(http://localhost:5001/vendor/zone.js/dist/zone.js:125:47)在XMLHttpRequest.ZoneTask。调用(http://localhost:5001/vendor/zone.js/dist/zone.js:293:33)加载错误http://localhost:5001/traceur无法将Transbiler加载到Transbilehttp://localhost:5001/vendor/@角度/形状/索引。js错误加载http://localhost:5001/vendor/@角度/形状/索引。js作为来自的“@angular/forms”http://localhost:5001/app/app.module.js ; 区域:;任务:promise。然后值:错误:(SystemJS)XHR错误(404未找到)正在加载http://localhost:5001/traceur(…)(SystemJS)XHR错误(404未找到)正在加载http://localhost:5001/traceur错误:XHR错误(404未找到)正在加载http://localhost:5001/traceur在XMLHttpRequest中。wrapFn[as_onreadystatechange](http://localhost:5001/vendor/zone.js/dist/zone.js:636:29)在分区公使馆。调用任务(http://localhost:5001/vendor/zone.js/dist/zone.js:225:37)在这个区域。运行任务(http://localhost:5001/vendor/zone.js/dist/zone.js:125:47)在XMLHttpRequest.ZoneTask。调用(http://localhost:5001/vendor/zone.js/dist/zone.js:293:33)加载错误http://localhost:5001/traceur无法将Transbiler加载到Transbilehttp://localhost:5001/vendor/@角度/形状/索引。js错误加载http://localhost:5001/vendor/@角度/形状/索引。js作为来自的“@angular/forms”http://localhost:5001/app/app.module.jsconsoleError@zone。js:344区域。js:346错误:未捕获(promise中):错误:(SystemJS)XHR错误(404未找到)加载http://localhost:5001/traceur(…)consoleError@zone.js:346

罪魁祸首是:

无法加载转译器转译http://localhost:5001/vendor/@角/形式/index.js

加载错误http://localhost:5001/vendor/@角度/形状/索引。js作为来自的“@angular/forms”http://localhost:5001/app/app.module.js

app.module.ts

import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { routing } from './app.routes';

import { AppComponent }  from './app.component';
import { FactoryFormComponent } from "./factory/factory-form.component";
import { SupplierFormComponent } from "./supplier/supplier-form.component";
import { BusinessAreaFormComponent } from './business-area/business-area-form.component';
import { HomeComponent } from "./home/home.component";

import { FactoryService } from "./factory/factory.service";
import { SupplierService } from "./supplier/supplier.service";
import { AppService } from "./shared/app.service";
import { UtilityService } from "./shared/utility.service";
import { HomeService } from "./home/home.service";
import { BusinessAreaService } from './business-area/business-area.service';


@NgModule({
    imports: [BrowserModule, routing, FormsModule, HttpModule],
    declarations: [AppComponent, HomeComponent, FactoryFormComponent, SupplierFormComponent, BusinessAreaFormComponent],
    bootstrap: [AppComponent],
    providers: [AppService, UtilityService, FactoryService, SupplierService, HomeService, BusinessAreaService]
})
export class AppModule { }

packages.json

{
  "name": "xxxx",
  "version": "0.0.0",
  "license": "xxxx",
  "angular-cli": {},
  "scripts": {
    "start": "ng serve",
    "postinstall": "typings install",
    "lint": "tslint \"src/**/*.ts\"",
    "test": "ng test",
    "pree2e": "webdriver-manager update",
    "e2e": "protractor"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "2.0.0-rc.5",
    "@angular/compiler": "2.0.0-rc.5",
    "@angular/core": "2.0.0-rc.5",
    "@angular/forms": "2.0.0",
    "@angular/http": "2.0.0-rc.5",
    "@angular/platform-browser": "2.0.0-rc.5",
    "@angular/platform-browser-dynamic": "2.0.0-rc.5",
    "@angular/router": "3.0.0-rc.1",
    "@angular/router-deprecated": "2.0.0-rc.2",
    "@angular/upgrade": "2.0.0-rc.5",
    "angular2-in-memory-web-api": "0.0.20",
    "systemjs": "0.19.38",
    "core-js": "^2.4.0",
    "reflect-metadata": "^0.1.3",
    "rxjs": "5.0.0-beta.12",
    "zone.js": "^0.6.12",
    "bootstrap": "^3.3.6",
    "es6-shim": "0.35.1",
    "ng2-bootstrap": "^1.0.17"
  },
  "devDependencies": {
    "angular-cli": "1.0.0-beta.6",
    "codelyzer": "0.0.20",
    "cucumber": "^1.2.1",
    "ember-cli-inject-live-reload": "1.4.0",
    "jasmine-core": "2.4.1",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "0.13.22",
    "karma-chrome-launcher": "0.2.3",
    "karma-jasmine": "0.3.8",
    "protractor": "3.3.0",
    "protractor-cucumber-framework": "^0.6.0",
    "ts-node": "0.5.5",
    "tslint": "3.11.0",
    "typescript": "^1.8.10",
    "typings": "^1.0.5"
  }
}

system-config.ts

// SystemJS configuration file, see links for more information
// https://github.com/systemjs/systemjs
// https://github.com/systemjs/systemjs/blob/master/docs/config-api.md

/***********************************************************************************************
 * User Configuration.
 **********************************************************************************************/
/** Map relative paths to URLs. */
const map: any = {
};

/** User packages configuration. */
const packages: any = {
};

////////////////////////////////////////////////////////////////////////////////////////////////
/***********************************************************************************************
 * Everything underneath this line is managed by the CLI.
 **********************************************************************************************/
const barrels: string[] = [
    // Angular specific barrels.
    '@angular/core',
    '@angular/common',
    '@angular/compiler',
    '@angular/http',
    '@angular/router',
    '@angular/platform-browser',
    '@angular/platform-browser-dynamic',
    '@angular/forms',

    // Thirdparty barrels.
    'rxjs',
    'ng2-bootstrap',

    // App specific barrels.
    'app',
    'app/shared',
    'app/factory',
    'app/data',
    'app/supplier',
    'app/home',
    'app/business-area',
    'app/contact',
  'app/relationship',
  /** @cli-barrel */
];

const cliSystemConfigPackages: any = {};
barrels.forEach((barrelName: string) => {
    cliSystemConfigPackages[barrelName] = { main: 'index' };
});

/** Type declaration for ambient System. */
declare var System: any;

// Apply the CLI SystemJS configuration.
System.config({
    map: {
        '@angular': 'vendor/@angular',
        'rxjs': 'vendor/rxjs',
        'main': 'main.js',
        'moment': 'vendor/moment/moment.js',
        'ng2-bootstrap': 'vendor/ng2-bootstrap/ng2-bootstrap.js'
    },
    packages: cliSystemConfigPackages
});

// Apply the user's configuration.
System.config({ map, packages });

angular-cli-build.js

// Angular-CLI build configuration
// This file lists all the node_modules files that will be used in a build
// Also see https://github.com/angular/angular-cli/wiki/3rd-party-libs

/* global require, module */

var Angular2App = require('angular-cli/lib/broccoli/angular2-app');

module.exports = function (defaults) {
    return new Angular2App(defaults, {
        vendorNpmFiles: [
          'systemjs/dist/system-polyfills.js',
          'systemjs/dist/system.src.js',
          'zone.js/dist/**/*.+(js|js.map)',
          'es6-shim/es6-shim.js',
          'reflect-metadata/**/*.+(ts|js|js.map)',
          'rxjs/**/*.+(js|js.map)',
          '@angular/**/*.+(js|js.map)',
          'ng2-bootstrap/**/*.js',
          'moment/moment.js',
          'bootstrap/dist/**/*'
        ]
    });
};

我似乎无法理解为什么它无法加载表单。它确实在与RC4合作……欢迎任何建议。

共有2个答案

何兴邦
2023-03-14

为了能够从RC04迁移到RC05,我相信您必须使用旧版本的表单模块

"@angular/forms": "version 0.3.0"

我会建议直接尝试更新到angular 2 2 . 0 . 0版本。

巫马善
2023-03-14

Angular团队已经改变了他们关于软件包中ES版本的政策。在过去,你有ES5脚本,所有的东西都很有魅力。目前,包内的文件是用ES6编写的。SystemJS从“某处”找到< code > import { something };内部,并尝试将脚本转换到ES5(这是traceur的目的)。

解决方案:更改SystemJS配置或设置traceur以在客户端浏览器中传输脚本。

我更喜欢第一种方法,因为它更快、更容易设置:

系统配置文件:

...
const packages: any = {
  'rxjs' : {main: 'Rx'},
  '@angular/core' : {main: 'bundles/core.umd.js'},
  '@angular/common' : {main: 'bundles/common.umd.js'},
  '@angular/upgrade' : {main: 'bundles/upgrade.umd.js'},
  '@angular/compiler' : {main: 'bundles/compiler.umd.js'},
  '@angular/forms' : {main: 'bundles/forms.umd.js'},
  '@angular/router' : {main: 'bundles/router.umd.js'},
  '@angular/platform-browser' : {main: 'bundles/platform-browser.umd.js'},
  '@angular/platform-browser-dynamic': {main: 'bundles/platform-browser-dynamic.umd.js'},
  '@angular/http' : {main: 'bundles/http.umd.min.js'},
...

此策略的缺点是一个文件中有整个包。这可能会使调试更加困难。

另外,请记住,您将不被允许访问angular team标记为私有的API。这也是最近的变化。

更多信息,请点击这里:https://github.com/angular/angular/blob/master/CHANGELOG.md

 类似资料:
  • 网页迁移是将网页从一个主机移动到另一个主机的过程。 这个过程是由于各种原因完成的,其中的一些原因是 - 您不再支持托管公司的支持 另一个托管的价格更便宜 实际托管计划不能满足您的需求了 所提供的技术已经不再有竞争力了等等 由于迁移是一个过程,因此需要采取以下步骤以最短的停机时间完成网页。 我们必须像前几章所讨论的那样完全备份网站代码网页和数据库。 上传新的托管备份文件。 解压公用文件夹中的文件。

  • 问题内容: 我正在尝试使用JavaFX的WebView加载此站点,但我得到的只是一个空白屏幕。WebView在其他站点上运行良好。它在ACID3上获得100/100并加载其他HTTPS站点,没有任何问题。 我也找不到该网站的任何特别错误。它具有由适当的CA签名的适当的,未过期的证书,并且SSL Labs报告为B级。我尝试了所有主要的浏览器,但没有一个报告任何与证书或SSL相关的问题;该网站对所有这

  • 今天我启动了我的MAMP本地服务器,我的Wordpress安装无法加载。它将尝试加载15-20秒,然后给我一个ERR_CONNECTION_TIMED_OUT错误。昨天一切正常,我绝对没有改变MAMP或我的网站的文件导致这个问题,所以这个问题对我来说真的很令人沮丧和神秘。 我不认为实际的MAMP服务器是一个问题,因为当我启动服务器时,我可以单击“打开WebStart页面”,它将正常加载,只有我的网

  • 我正在尝试在Laravel中创建外键,但是当我使用迁移表时,出现以下错误: 我的迁移代码如下: 优先级迁移文件 用户迁移文件 任何关于我做错了什么的想法,我现在就想知道,因为我有很多表需要创建,例如用户、客户、项目、任务、状态、优先级、类型、团队。理想情况下,我希望创建使用外键保存此数据的表,即和等。 希望有人能帮助我开始。

  • 我需要将存在于Web链接上的数据上传到hdfs,例如“博客”。 现在,我正在寻找实现这一目标的选项,可以找到以下链接: http://blog . cloud era . com/blog/2012/09/analyzing-Twitter-data-with-Hadoop/ 但是通过水槽文档阅读,我不清楚如何设置水槽源来指向博客内容所在的网站。 根据我对 fluem 文档的理解,需要有网络服务器

  • 在根据https://wiki.eclipse.org/new_maven_coordines和Maven central从Java 8迁移到Java 11并从EE切换到最新的Jakarta库时,我们在(仍然基于SOAP的)客户端应用程序中遇到了以下运行时异常: Getting java.lang.ClassNotFoundException:com.sun.xml.internal.ws.spi