尝试导入css animator时,Angular2/Typescript返回404未找到

尝试导入css animator时,Angular2/Typescript返回404未找到,typescript,angular,angular2-directives,polyfills,Typescript,Angular,Angular2 Directives,Polyfills,我刚开始玩angular2,试着用它做一些动画 package.json "dependencies": { "@angular/common": "2.0.0-rc.3", "@angular/compiler": "2.0.0-rc.3", "@angular/core": "2.0.0-rc.3", "@angular/forms": "0.1.1", "@angular/http": "2.0.0-rc.3", "@angular/plat

我刚开始玩angular2,试着用它做一些动画

package.json

"dependencies": {
    "@angular/common": "2.0.0-rc.3",
    "@angular/compiler": "2.0.0-rc.3",
    "@angular/core": "2.0.0-rc.3",
    "@angular/forms": "0.1.1",
    "@angular/http": "2.0.0-rc.3",
    "@angular/platform-browser": "2.0.0-rc.3",
    "@angular/platform-browser-dynamic": "2.0.0-rc.3",
    "@angular/router": "3.0.0-alpha.7",
    "@angular/router-deprecated": "2.0.0-rc.2",
    "@angular/upgrade": "2.0.0-rc.3",
    "angular2-in-memory-web-api": "0.0.12",
    "bootstrap": "^3.3.6",
    "chokidar": "^1.6.0",
    "core-js": "^2.4.0",
    "css-animator": "^1.2.4",
    "http-proxy": "^1.14.0",
    "reflect-metadata": "^0.1.3",
    "rxjs": "5.0.0-beta.6",
    "systemjs": "0.19.27",
    "zone.js": "^0.6.12"
 }
index.html

<html>
  <head>
   <title>Angular 2 QuickStart</title>
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1">
   <link rel="stylesheet" href="app/css/bootstrap.css">
   <link rel="stylesheet" href="app/css/style.css">
   <!-- 1. Load libraries -->
 <!-- Polyfill(s) for older browsers -->
    <script src="node_modules/core-js/client/shim.min.js"></script>
    <script src="node_modules/zone.js/dist/zone.js"></script>
    <script src="node_modules/reflect-metadata/Reflect.js"></script>
   <script src="node_modules/systemjs/dist/system.src.js"></script>
   <script src="node_modules/css-animator/builder/animation_builder.js">      </script>
   <!-- 2. Configure SystemJS -->
   <script src="systemjs.config.js"></script>
   <script>
     System.import('app').catch(function(err){ console.error(err); });
   </script>
         </head>
     <!-- 3. Display the application -->
        <body class="bg-image">
          <my-app>Loading...</my-app>
          </body>
      </html>
自定义.animate.directive.ts

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',
    'css-animator':               'node_modules/css-animator'
  };
   var packages = {
    'app':                        { main: 'main.js',  defaultExtension: 'js' },
    'rxjs':                       { defaultExtension: 'js' },
    'angular2-in-memory-web-api': { main: 'index.js', defaultExtension: 'js'   },
     };
     System.config(config);
import {Directive, ElementRef, Renderer} from '@angular/core';
 import {AnimationService, AnimationBuilder} from 'css-animator';

 @Directive({
    selector: '[login-method]',
    host: {
      '(click)':'onClick()'
   }
})

export class LoginOptionsDirective{
   private animator : AnimationBuilder;

   constructor(animationService: AnimationService, private el: ElementRef, private renderer: Renderer){
      this.animator = animationService.builder();
  }

  onclick(){
      this.renderer.setElementStyle(this.el, 'color','black');
      console.log(this.el.nativeElement.getAttribute("login-method"));
   }
 }

我得到
animation\u builder.js:434未捕获引用错误:未定义导出
localhost/:18错误:错误:XHR错误(404未找到)加载http://localhost:3000/node_modules/css-浏览器控制台上的animator(…)

有人能帮我吗


谢谢。

您将直接在
部分包含
动画_builder.js

<script src="node_modules/css-animator/builder/animation_builder.js"></script>

您会得到一个ReferenceError,因为包中包含的单个文件被编译为CommonJS,浏览器本机无法理解

尝试删除该行,如果您在某处导入文件,SystemJS将自动加载这些文件。SystemJS也理解CommonJS

或者,您可以在
部分中包含包提供的SystemJS捆绑包。如果然后从css animator导入一个模块,SystemJS已经注册了这个模块,可以立即加载它

您可以将缩小或未缩小的捆绑包包括在内,如下所示:

<!-- Unminified Source -->
<script src="node_modules/css-animator/bundles/css-animator.js"></script>

<!-- Minified Source -->
<script src="node_modules/css-animator/bundles/css-animator.min.js"></script>


免责声明:我是此软件包的作者。

我认为rc3不存在。根据
animation\u builder.js:434 Uncaught ReferenceError:exports未定义
已解决,但我仍然有一个错误
zone.js:101 GEThttp://localhost:3000/node_modules/css-动画师/404(未找到)
我想你必须告诉SystemJS,css animator的主要入口点是什么。尝试将
'css-animator':{main:'index.js',defaultExtension:'js'},
添加到
对象中。如果您有时间,您可能需要研究前端依赖关系管理。它会为您生成SystemJS配置文件。谢谢您的帮助。。我必须在我的软件包中添加'cssanimator':{main:'index.js',defaultExtension:'js'}。