npm

For a long time I have been reluctant to publish to npm. This is for a number of reasons:

  1. My code is not polished enough.
  2. I don’t consider my solutions to be desirable enough for others to use.
  3. I don’t fancy the responsibility of maintaining a package once people are dependent on it.
  4. I thought it was just for Node modules and I don’t use Node.
  5. I was a bit afraid of how complicated it might become.

Recently though, I decided I would use Node for a quick solution that I needed to generate some code for me. Node modules and JS template literals provided me with my quick fix – no new templating language necessary :)

But a general-purpose templated generator still needs build scripts and templates. And the packaged module looked good for doing that part too. And that led to a neat npm-based solution, along the lines of yeoman and its generators.

So I gave it a name (which I have been meaning to use for years), split the generator and build script into 2 separate packages and published them both to npm. It was easy. And now they are there, I can consume my own solution more easily across multiple projects.

npm even kindly generates an executable entry point for me in its folder in the path, for greater ease of use.

I was a bit concerned that I was polluting npm with something that others will surely not want or be able to use. But there is a lot of dross in npm and I soon got over that guilt. Leaving me with a brilliant solution to a problem I wasn’t even aware I had!

I recommend it to you all…

npm init
npm login
npm publish

And it’s even better when your source is hosted in a public place such as Github.

I am now going to go back through my library of code and see if there are any libs or widgets which are worth sharing, or at least hosting more centrally so that I can get to them

Leave a Reply

Your email address will not be published. Required fields are marked *