10

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/angular2-infinite-scroll@0.1.2"></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?

Hongbo Miao
  • 45,290
  • 60
  • 174
  • 267

1 Answers1

9

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/angular2-infinite-scroll@0.1.2'
},
packages: {
    [...],
    'angular2-infinite-scroll': {
        main: 'angular2-infinite-scroll.js',
        defaultExtension: 'js'
    }
},

working Plunker

Maximilian Riegler
  • 22,720
  • 4
  • 62
  • 71