当我今天进入https://angular.io/docs/ts/latest/tutorial/的快速入门教程时,

npm start


我看到了两个404错误缺失:

404 GET /node_modules/@angular/platform-browser-dynamic/platform-browser-dynamic.umd.js
404 GET /node_modules/@angular/core/core.umd.js


我已经直接从教程中复制了systemjs.config.js和其他文件(请参见下文)。这是使用2.0.0-rc.2。现在有没有Angular专家知道快速入门代码有什么问题吗?我应该改用webpack工具吗?



/**
 * System configuration for Angular 2 samples
 * Adjust as necessary for your application needs.
 */
(function(global) {
  // map tells the System loader where to look for things
  var map = {
    'app':                        'app', // 'dist',
    '@angular':                   'node_modules/@angular',
    'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api',
    'rxjs':                       'node_modules/rxjs'
  };
  // packages tells the System loader how to load when no filename and/or no extension
  var packages = {
    'app':                        { main: 'main.js',  defaultExtension: 'js' },
    'rxjs':                       { defaultExtension: 'js' },
    'angular2-in-memory-web-api': { main: 'index.js', defaultExtension: 'js' },
  };
  var ngPackageNames = [
    'common',
    'compiler',
    'core',
    'http',
    'platform-browser',
    'platform-browser-dynamic',
    'router',
    'router-deprecated',
    'upgrade',
  ];
  // Individual files (~300 requests):
  function packIndex(pkgName) {
    packages['@angular/'+pkgName] = { main: 'index.js', defaultExtension: 'js' };
  }
  // Bundled (~40 requests):
  function packUmd(pkgName) {
    packages['@angular/'+pkgName] = { main: pkgName + '.umd.js', defaultExtension: 'js' };
  }
  // Most environments should use UMD; some (Karma) need the individual index files
  var setPackageConfig = System.packageWithIndex ? packIndex : packUmd;
  // Add package entries for angular packages
  ngPackageNames.forEach(setPackageConfig);
  var config = {
    map: map,
    packages: packages
  };
  System.config(config);
})(this);

最佳答案

您的packUmd函数应类似于:

// Bundled (~40 requests):
function packUmd(pkgName) {
  packages['@angular/' + pkgName] = {
     main: '/bundles/' + pkgName + '.umd.js', //bundles path
     defaultExtension: 'js'
  };
}


通知/bundles/

关于javascript - Angular2 RC2-快速入门项目无法生成2个.umd.js文件,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37866936/

10-12 13:16