How to use client side npm libraries with meteor 1.3?


I am trying to use client side npm library (video.js and videojs-record plugin). But it is not exactly clear for me what is the correct way to do it. videojs-record documentation states that you have to simply include js file, and thats fine nothing simpler than that but with meteor is a bit unclear. In meteor npm documentation it is said to install lib and use require(yourlib). So after some tries I ended up installing npm packages and doing this in client/lib/config.js file:

import ‘/node_modules/videojs-record/src/css/videojs.record.css’;
import ‘/node_modules/video.js/dist/video-js.css’;
videojs = require(‘video.js’);

It kinda works, but if I use links to get to the recorder page I get Unable to find plugin: record. When I refresh its fine. I think I am getting there but still missing something. Interestingly video.js works that way but with a lag - first standard html5 video is loaded and after a moment video.js skin is added. So my question is how can I simply use those client side js in meteor, so it would be exactly the same as simply adding them to head in another application. I just want those scripts to be loaded all the time and don’t want any hacks with $.getScript and onCreate (I tried this too but it also wasn’t working).

So no one uses client side npm libraries that just simply needs to have js file loaded and no one knows how to use it with meteor?

You could try doing it Meteor old-school. Just put the js file into the client/compatibility/ folder.

Use the Meteor-node-stubs package.