【发布时间】:2016-06-28 11:19:04
【问题描述】:
我正在尝试将节点模块导入 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"
我错过了什么吗?
【问题讨论】:
-
你遇到了什么错误?
-
Uncaught SyntaxError: Unexpected token
-
一个问题,我应该浏览库吗?
-
将尽快创建一个 plunker
-
问题解决了吗?请发布解决方案。我也有类似的问题。
标签: angular node-modules systemjs