node package manager


Dependencies manager



Puddi is a node.js library for dependencies managing, made for people who hate managing them.

It works by adding a single raw file for each module, which describes its internal specificities.

To install puddi, a simple npm install puddi should be sufficient.


The file is encoded using the YAML syntax. (JSON is great, but not really human- readable.)

  name: my_module
    - other_module
    - another_module.child_module


Assuming you want to create a javascript game, you will probably have a client and a server, and some shared structures. So your file hierarchy should be :

  • application
    • structure
    • client
    • server

We have four modules here. The structure module, which will contain our shared data structures, the modules for both the client and the server and, lastly, the main application module.

Using puddi, our file hierarchy will become :

  • application
    • structures
      • module.yml
    • client
      • module.yml
    • server
      • module.yml
    • module.yml

The structures module doesn't depend on anything, but the client and the server modules both depend on the structures module, and the application module depends on both the client and the server modules.

So this is what the module.yml file should be like :


  name: application
    - client
    - server


  name: client
    - application.structures


  name: server
    - application.structures


  name: structures

Note that a module inherits its super module's scope. So instead of application.structures, we can simply write structures. It's juste a matter of verbosity.

Now, using puddi, you can simply select the module to resolve (assuming you are in your application directory) :

puddi . application.client --print | xargs -n 1 echo "Client-side application contains this module :"
puddi . application.server --print | xargs -n 1 echo "Server-side application contains this module :"

Only the required module and its dependencies will be printed, in a dependencies-aware order.

If, for some reason, one of your folders' name contains a line return, the output will be broken. In that case, replace --print with --print0, which will use a null character as a separator. You will then be able to efficiently split the output with a command like xargs with its -0 option.

usefuls examples

What we have done is not fun. Who dares about print some folders path in a specific order ?

But modern shells are powerful. Very powerful. And same is for node libaries !

Using the power of the xargs, you will be able to execute binaries in a specific order, and do some magic with it.

For instance (bash file) :

#!/usr/bin/env bash 
function forEachJavascriptFile() {
  ../bin/puddi.js "${1}" "${2}" --print | xargs -I X find X -maxdepth 1 -name '*.js' -exec "${3}" {} \;
# Want to check your code with JSHint ? 
forEachJavascriptFile . application jshint
# This will process every client files using UglifyJS, and write the output in the build folder 
forEachJavascriptFile . application.client uglifyjs > build/client.js
forEachJavascriptFile . application.server uglifyjs > build/server.js

puddi as node.js library

You can obviously use Puddi as a node.js library.

Very simple showcase :

var puddi = require('puddi');'.', function (tree) {
  var client = puddi.find(tree, 'application.client');
  if (client !== client)
    puddi.resolve(client, function (module) {
      console.log('Module to load : ' + + ' (' + + ')');
    console.log('There is no client in this application !');