NodeJS project management with NPM

I've seen questions for this topic come up repeatedly so I figured I'd throw something down to refer people to. :)

If you're interested in NodeJS, and I'm betting that you are, then you'll be wanting to make a project. There area few things you can do. Many, not all, people in the NodeJS community use Git and Github for source control and hosting respectively. You'll do fine hunting around there for things people have made on Github. Alternatively, the NPM repository hosts stable versions of each module and provides some conveniences for installation.

At the start you may be tempted to just something like:

npm install module

I'd recommend against this. While it will work in a pinch. But, a better approach would be to use the package.json file. At first it seems strange to do so, but it becomes natural very quickly. With this approach you get the benefit of having a file you can check in. This means that you can throw it in your versioning system and once done, type:

npm install .

This will install your current project and all of it's dependencies. It makes it really nice when moving around machines. I usually work on two machines and then deploy on another. Having a file that makes installation easier is really nice. The file itself would looks something similar to this:

Note that you do not need to put your project in NPM. We're talking about managing your dependencies and other project information. However, one caveat is that this file needs to be proper JSON.

If you're interested in more, take a look by typing:

man npm-json

Hope that helps. Happy Hacking.

Posted
Views | Favorited 0 Times
Filed under:

Comments (0)

Leave a comment...