我使用带有Typescript和Systems.js的fountainJS Angular2生成器来搭建项目。https://github.com/FountainJS/generator-fountain-angular2
但我有个问题,我不能将组件添加到项目中。当我输入import {GOOGLE_MAPS_DIRECTIVES}时,我得到了这个错误
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
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'
}
}
}
});发布于 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中为其添加路由
routes: {
'/node_modules': 'node_modules',或者,您可以使用jspm而不是npm来安装angular2-google-map:
jspm install angular2-google-mapsjspm会修改jspm.config.js,为angular2-google-map添加正确的映射。
但是,在修复了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这可能意味着最新的angular2-google-maps生成器-喷泉-angular2安装了is incompatible with angular2-rc4。
https://stackoverflow.com/questions/39311843
复制相似问题