Is there a way to check if package exists?

Tried to google about it and didn’t find a way to check in server side code if some package is installed or missing. Any suggestions how to achieve this functionality?

There’s not really an official way but you can check for the existence of Package['author:package-name'].


Thanks mate! It works like a charm :slight_smile:

Is there a way to do this in a Blaze template?

I tried this, but it did not work:

{{#if Package["my:package"] }}

Just register a global helper. Something as simple as this:

Template.registerHelper('packageIsInstalled', function (packageName) {
    return !!Package[packageName];

Then in your HTML use it like this:

{{#if packageIsInstalled 'my:package'}}

Thanks. It seems a bit strange, though, that this would work, as the syntax in the template is exactly the same as in Package["my:package"].

Sorry, my bad. Should be:

{{#if packageIsInstalled 'my:package' }} ... {{/if}}

I edited my original reply as well, for those in a rush.


Ah, thanks :slight_smile:

1 Like