FountainJS Angular2安装组件angular2-google-maps问题

时间:2016-09-03 22:22:40

标签: google-maps angular typescript yeoman systemjs

我使用了带有Typescript和Systems.js的fountainJS Angular2生成器 用于脚手架的项目。 https://github.com/FountainJS/generator-fountain-angular2

但是我遇到了问题,我无法将组件添加到项目中。 当我放入导入{GOOGLE_MAPS_DIRECTIVES}时 我收到此错误

system.src.js:1057 GET http://localhost:3000/node_modules/angular2-google-maps/core/index.js 404 (Not Found)

enter image description here

我经历过那个 https://angular-maps.com/docs/getting-started.html “入门”部分并将一些代码添加到jspm.config.js文件中,但我的项目中没有angular-cli-build.js文件。

我的jspm.config.js

SystemJS.config({
  packageConfigPaths: [
    'npm:@*/*.json',
    'npm:*.json',
    'github:*/*.json'
  ],
  map: {
    'angular2-google-maps': 'node_modules/angular2-google-maps',
    '@angular/common': 'npm:@angular/common@2.0.0-rc.4',
    '@angular/compiler': 'npm:@angular/compiler@2.0.0-rc.4',
    '@angular/core': 'npm:@angular/core@2.0.0-rc.4',
    '@angular/http': 'npm:@angular/http@2.0.0-rc.4',
    '@angular/platform-browser': 'npm:@angular/platform-browser@2.0.0-rc.4',
    '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic@2.0.0-rc.4',
    '@angular/router': 'npm:@angular/router@3.0.0-beta.2',
    'es6-shim': 'npm:es6-shim@0.35.1',
    'os': 'github:jspm/nodelibs-os@0.2.0-alpha',
    'process': 'github:jspm/nodelibs-process@0.2.0-alpha',
    'reflect-metadata': 'npm:reflect-metadata@0.1.3',
    'rxjs': 'npm:rxjs@5.0.0-beta.6',
    'ts': 'github:frankwallis/plugin-typescript@4.0.16',
    'zone.js': 'npm:zone.js@0.6.17'
  },
  packages: {
    'angular2-google-maps/core': {
      defaultExtension: 'js',
      main: 'index.js' // you can also use core.umd.js here, if you want faster loads
    },
    'github:frankwallis/plugin-typescript@4.0.16': {
      'map': {
        'typescript': 'npm:typescript@1.8.10'
      }
    },
    'github:jspm/nodelibs-os@0.2.0-alpha': {
      'map': {
        'os-browserify': 'npm:os-browserify@0.2.1'
      }
    }
  }
});

1 个答案:

答案 0 :(得分:0)

您收到node_modules/angular2-google-maps/core/index.js 404 (Not Found)因为npm run serve使用的网络服务器无法使用node_modules。

如果您需要可以通过客户端代码访问node_modules,则必须在conf/browsersync.conf.js中为其添加路由:

  routes: {
    '/node_modules': 'node_modules',

或者,您可以使用jspm而不是npm来安装angular2-google-maps:

jspm install angular2-google-maps

和jspm将修改jspm.config.js以为angular2-google-maps添加正确的映射。

但是,在404错误修复后,我现在正在

system.src.js:123 Uncaught (in promise) Error: (SystemJS) core_1.NgModule is not a function
TypeError: core_1.NgModule is not a function

这可能意味着由generator-fountain-angular2安装的最新angular2-google-maps is incompatible with angular2-rc4