Işık Işık - 11 months ago 62
Node.js Question

Installing Meteor packages globally

Is there a way to install meteor packages globally?

So, having the once globally installed packages installable without internet connection for projects created later, avoid repetitive downloading, and other benefits one may imagine.

Like in Node.js, using npm command (of Node Package Manager) with

npm install -g
, doing so npm installs node packages into a global directory and when wanted to be loaded from javascript programs, loading from there if available, as well as looking in and loading packages from project's node modules folder.

Answer Source

Meteor already downloads packages into a global repository that all your local apps benefit off of.

So if you meteor add iron:router@1.0.7 it is downloaded and added to your project. Next time another project requires the same version, it is used off that same spot.

Also, there is a PACKAGES_DIR environment variable, when set, allows you to keep your own local packages centrally, so that you can share them among projects. In fact, you can keep that on a network drive (NFS) which your whole team can mount and consume centrally.

Yet, there is an inherent problem. Meteor's version resolver looks up for updates unless you pin down your package dependency versions so that is exactly why meteor seems to be so desperate to be connected.

Even if you pin your dependencies, the packages you depend on may not have (which apparently is the case for most packages) so Meteor keeps looking for updates to the whole package tree and downloads those that it deems satisfying the version constraint resolver.

The good news is, they are constantly improving their tooling, requiring lower number of lookups, faster builds, better search etc.

All in all, in essence, there is not much you can do unless Meteor provides some way of hosting an entire mirror of its package repository for you to consume offline. And I guess it is very unlikely to happen.

Meteor is a tool for the connected world and it does assume your connectivity. Heck, the whole journey begins with a curl https://install.meteor.com/ | sh

And yes, it would be great if we could hack away on a remote beach, or the 12 hour flight to that beach.

Until then, happy coding online ;)