1

当我开始收到以下错误消息时,我试图让一个 cerialize 包显示在 dist 目录的供应商目录中,尽管 ng build 和 ng server cmds 工作。当我在浏览器中尝试 localhost:4200 时出现错误

编辑 2

此错误可能不依赖于 cerialize,因为在删除应用程序中对 cerialize 的所有引用后,执行 ng build 和 ng-serve,问题仍然存在

错误(编辑 1 以获得完整输出)

zone.js:323 Error: ReferenceError: cliSystemConfigPackages is not defined(…)
ZoneDelegate.invoke 
@ zone.js:323Zone.run 
@ zone.js:216(anonymous function) 
@ zone.js:571ZoneDelegate.invokeTask 
@ zone.js:356Zone.runTask 
@ zone.js:256drainMicroTaskQueue 
@ zone.js:474ZoneTask.invoke @ zone.js:426

// The actual zone.js line referenced
ZoneDelegate.prototype.invoke = function (targetZone, callback, applyThis, applyArgs, source) {
                return this._invokeZS
                    ? this._invokeZS.onInvoke(this._invokeDlgt, this.zone, targetZone, callback, applyThis, applyArgs, source)
                    : callback.apply(applyThis, applyArgs);
            };

// zone popup error (popup on red x at zone error position in trace)
Error: ReferenceError: cliSystemConfigPackages is not defined
at barrels.forEach (http://localhost:4200/system-config.js:79:5)
at Array.forEach (native)
at eval (http://localhost:4200/system-config.js:78:9)
Evaluating http://localhost:4200/system-config.js
Error loading http://localhost:4200/system-config.js

系统配置.ts

/** Map relative paths to URLs. */
const map: any = {
  '@angular2-material': 'vendor/@angular2-material',
  'cerialize': 'vendor/cerialize/dist/serialize.js',
  'immutable': 'vendor/immutable',
  'lodash': 'vendor/lodash/lodash.js'
};

/** User packages configuration. */
const materialPackages: string[] = [
  'core',
  'button',
  'card',
  'checkbox',
  'grid-list',
  'icon',
  'input',
  'list',
  'progress-bar',
  'progress-circle',
  'radio',
  'sidenav',
  'slide-toggle',
  'tabs',
  'toolbar',
];

/** User packages configuration. */
const packages: any = createCustomConfig(materialPackages);

function createCustomConfig(packages: string[]): any {
  return packages.reduce(
      (packageConfig: any, packageName: string) => {
        packageConfig[`@angular2-material/${packageName}`] = {
          format: 'cjs',
          defaultExtension: 'js',
          main: packageName
        };
        return packageConfig;
      }, {});
}

////////////////////////////////////////////////////////////////////////////////////////////////
/***********************************************************************************************
 * 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',

  // Thirdparty barrels.
  'rxjs',

  // App specific barrels.
  'app',
  'app/shared',
  'app/shared/side-nav',
  'app/+new-patient',
  'app/registration/name',
  'app/registration/patient',
  'app/registration/age',
  'app/registration/gender',
  'app/registration/marital-status',
  'app/registration/religion',
  'app/registration/language',
  /** @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'
  },
  packages: cliSystemConfigPackages
});

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

角-cli-build.js

/* 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/**/*.+(js|js.map)',
      'rxjs/**/*.+(js|js.map)',
      '@angular/**/*.+(js|js.map)',
      '@angular2-material/**/*',
      'angularfire2/**/*.js',
      'core-js/client/core.js',
      'cerialize/**/*',
      'firebase/lib/*.js',
      'immutable/**/*.js',
      'lodash/lodash.js'
    ]
    /*   sassCompiler: {
     includePaths: [
     'src/app/style' <-- directory for SASS reference files
     ] */
  });
};

在我尝试使用 cerialize 包之前,我的应用程序运行良好。这是我第一次真正看到这个错误。

干杯和感谢

4

0 回答 0