Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a NPM package correctly in the plunker?

I got an error when using angular2-infinite-scroll. I want to reproduce it in a plunkr.

I tried to use npmcdn, so I add this line in the index.html file:

<script src="https://npmcdn.com/[email protected]"></script>

But I got the error:

Uncaught ReferenceError: require is not defined

This is my plunker.

How can I add a NPM package correctly in the plunker?

like image 686
Hongbo Miao Avatar asked Jun 16 '16 13:06

Hongbo Miao


1 Answers

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.

map: {
    [...],
    'angular2-infinite-scroll': 'https://npmcdn.com/[email protected]'
},
packages: {
    [...],
    'angular2-infinite-scroll': {
        main: 'angular2-infinite-scroll.js',
        defaultExtension: 'js'
    }
},

working Plunker

like image 94
rinukkusu Avatar answered Sep 20 '22 09:09

rinukkusu