Simple NPM module, how do I integrate into my Meteor 1.2 app?

Hi guys, I’m trying to use this lib to generate slugs for my records.

That’s pretty much all there is to it, I’m not really sure how to use NPM packages in my Meteor app.

npm install limax

var slug = require('limax');

var latin = slug('i ♥ latin'); // i-love-latin
var cyrillic = slug('Я люблю русский'); // ya-lyublyu-russkij
var pinyin = slug('我爱官话'); // wo3-ai4-guan1-hua4
var romaji = slug('私は ひらがな が大好き'); // ha-hiragana-gaki

What is the easiest way to integrate this? Should I just upgrade my app to Meteor 1.3?

Ok, so I figured it out. It basically boils down to:

Add this package:


In packages.json add your module:

  "limax": "1.1.4"

In your server:

  'Helpers.generateSlug': function(value) {
    var slug = Meteor.npmRequire('limax');
    var sluggedValue = slug(value);
    return sluggedValue;

Easy enough, but with 1.3 it’s going to break something fierce. :frowning:

1 Like