首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >FountainJS Angular2安装组件angular2-google-maps问题

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

Stack Overflow用户
提问于 2016-09-04 06:22:40
回答 1查看 280关注 0票数 0

我使用带有Typescript和Systems.js的fountainJS Angular2生成器来搭建项目。https://github.com/FountainJS/generator-fountain-angular2

但我有个问题,我不能将组件添加到项目中。当我输入import {GOOGLE_MAPS_DIRECTIVES}时,我得到了这个错误

代码语言:javascript
复制
system.src.js:1057 GET http://localhost:3000/node_modules/angular2-google-maps/core/index.js 404 (Not Found)

我浏览了https://angular-maps.com/docs/getting-started.html“入门”部分,并在jspm.config.js文件中添加了一些代码,但我的项目中没有angular-cli-build.js文件。

我的jspm.config.js

代码语言:javascript
复制
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'
      }
    }
  }
});
EN

回答 1

Stack Overflow用户

发布于 2016-09-05 02:16:05

您正在获取node_modules/angular2-google-maps/core/index.js 404 (Not Found),因为npm run serve使用的web服务器不能使用node_modules。

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

代码语言:javascript
复制
  routes: {
    '/node_modules': 'node_modules',

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

代码语言:javascript
复制
jspm install angular2-google-maps

jspm会修改jspm.config.js,为angular2-google-map添加正确的映射。

但是,在修复了404错误之后,我现在得到

代码语言:javascript
复制
system.src.js:123 Uncaught (in promise) Error: (SystemJS) core_1.NgModule is not a function
TypeError: core_1.NgModule is not a function

这可能意味着最新的angular2-google-maps生成器-喷泉-angular2安装了is incompatible with angular2-rc4

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39311843

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档