将节点模块导入Angular 2

时间:2016-03-13 12:30:05

标签: angular node-modules systemjs

我正在尝试将节点模块导入Angular 2,但没有用。

如何实现这一目标?

我正在尝试将以下模块导入Angular 2: https://www.npmjs.com/package/countryjs

我是否需要使用system.js将其注册到当前应用程序中:

<!-- 2. Configure SystemJS -->
    <script>
      System.config({
        packages: {
          app: {
            format: 'register',
            defaultExtension: 'js'
          },
          map: {
              'countryjs': 'node_modules/countryjs/lib/countryjs'
          },
          meta: {
              // sets meta for modules within the package
              'vendor/*': {
                  'format': 'global'
              }
          }
        }
      });
      System.import('app/boot')
            .then(null, console.error.bind(console));


    </script>

然后在ts文件中,我使用:

import {} from "countryjs"

当我使用它(下面)时,它给我一个错误

import {Country} from "countryjs"

我错过了什么吗?

1 个答案:

答案 0 :(得分:3)

首先很抱歉没有发布这么久。

我终于找到了解决方案。请找到更改的system.js脚本:

sourcefile.m
相关问题