Angular2中节点数据包的导入错误 [英] Import error of node packet in Angular2

查看:71
本文介绍了Angular2中节点数据包的导入错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试包含node_module angular2-google-maps时,我遇到了一些奇怪的问题.我收到这些错误:

I am having some strange issues when I try to include the node_module angular2-google-maps. I get these errors:

angular2-polyfills.js:1243 Uncaught SyntaxError: Unexpected token <
    Evaluating http://127.0.0.1:3000/angular2-google-maps/core
    Error loading http://127.0.0.1:3000/public/main.ts

我看到该网址的路径错误: http://127.0. 0.1:3000/angular2-google-maps/core ,应为

I can see that the path is wrong to this url: http://127.0.0.1:3000/angular2-google-maps/core, it should be http://127.0.0.1:3000/node_modules/angular2-google-maps/core.js I guess?

我将软件包导入到我的组件中,如下所示:

I import the package in my component like this:

import { ANGULAR2_GOOGLE_MAPS_DIRECTIVES } from 'angular2-google-maps/core';

哪个应该是对的.我还想念其他东西吗?

Which should be right. Have I missed anything else?

推荐答案

如果您使用的是 angular2 -google-maps ,则应检查示例plnkr .

If you're using angular2-google-maps you should check the example plnkr.

请参阅config.js文件,其中包含以下内容

See the config.js file, it contains the following

packages: {
  'angular2-google-maps': {
    defaultExtension: 'js'
   }
}

那是你所缺少的部分.

这篇关于Angular2中节点数据包的导入错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆