Friday, February 13, 2015

Setting up a private NPM repository in an offline network

The organization I work in is disconnected from the internet.Yes, it is terrible. That's the reason I came up with this.

Effective web development requires good tools. Tools to help you lint, precompile css, test and run customized tasks. These tools exist and the comfortable way of doing this is using npm (Node Package Manager - comes bundled with nodejs). It allows you to easily install such tools.

Many developers are not familiar with these tools, and it is my job to acquaint them with better methods of developing software. One thing I learned is that the best chance to ease people into starting using a new technology is showing them that it is easy to use. And using these tools without simply running npm install karma is hard and annoying. The problem is, of course, npm install karma will not work for us because we are not connected to the internet and the central npm registry is not available for us.

So I looked for a way to make our own private npm registry. Like we have our own Nexus repository for Java artifacts.
I found several solutions.
There was one that required setting up a couch base instance. Too complicated.
I tried using npm_lazy and reggie but ran into too many bugs, and honestly these are not serious projects and it doesn't seem they will be maintained a lot longer.
Finally I stumbled upon a package sinopia, which seemed serious comparing to the former libs.

Sinopia now runs and workds and some teams are already using it. Still there are some small issues that I had to fix in the beginning.

So if you have a network behind a firewall and you need a private npm registry - use Sinopia! It's awesome! :)

2 comments:

  1. But how do you add packages for the first time?

    ReplyDelete
  2. Take a look at npmbox, it solve the offline problem in a very elegant way.

    ReplyDelete