[英]How to add a NPM package correctly in the plunker?
I got an error when using angular2-infinite-scroll . 使用angular2-infinite-scroll时出错了 。 I want to reproduce it in a plunkr.
我想在一个plunkr中重现它。
I tried to use npmcdn , so I add this line in the index.html file: 我尝试使用npmcdn ,所以我在index.html文件中添加了这一行:
<script src="https://npmcdn.com/angular2-infinite-scroll@0.1.2"></script>
But I got the error: 但是我得到了错误:
Uncaught ReferenceError: require is not defined
未捕获的ReferenceError:未定义require
How can I add a NPM package correctly in the plunker? 如何在plunker中正确添加NPM包?
Add it to the map
object in your config.js
file and possibly also in the packages
object, if the package doesn't have a index.js
. 如果包没有
index.js
,则将它添加到config.js
文件中的map
对象中,也可能添加到packages
对象中。
map: {
[...],
'angular2-infinite-scroll': 'https://npmcdn.com/angular2-infinite-scroll@0.1.2'
},
packages: {
[...],
'angular2-infinite-scroll': {
main: 'angular2-infinite-scroll.js',
defaultExtension: 'js'
}
},
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.