So, the instructions you have regarding npm modules, but you are doing local development. Here are some suggestions.
In terms of source code, you only need two types of require statements
var dep = require('somedep')
Use this for any core modules (e.g. fs ) and third-party modules that you need libraries that you include via npm (listing them in your .json packages as dependencies). Here you specify the unqualified name of the package and node finds the module according to its search algorithm.
var mymod = require('./lib/mymod')
Use this so that other modules in your project themselves along the path relative to the current javascript file.
This is all you need to do to handle javascript dependencies.
OK, now how do you install your dependencies?
For local development (in your original project tree) just enter cd into the project directory and run npm install , which will read your package.json file and install the modules you need in the node_modules subdirectory, and everything will be fine for local development.
If you really published it as an npm module, other users (and you can be either a developer or one of the โother usersโ) could install it using npm -g if you would like to access the binary utility project on their PATH , which should include /usr/lib/nodejs/lib/node_modules , but in this case npm -g will process both your code and your project dependencies at once.
This is where you get confused.
Therefore, according to the above, my dependencies should be installed as global modules.
You do not need to explicitly set the dependencies as global, only the top-level module that interests you, which in this case is your project. npm will handle dependencies automatically, which is its main goal in life. Project dependencies will not be installed globally for each user, but rather in the node_modules subdirectory of your project, which will be installed globally.
Here are the directories and what lives there:
~/yourproject : local development for your source code~/yourproject/node_modules : npm modules used by your project during development. Created / populated by running npm install in ~/yourproject/usr/lib/nodejs/lib/node_modules : npm modules (which may eventually include your project if you publish it to the npm registry) that are installed globally/usr/lib/nodejs/lib/node_modules/yourproject/node_modules : the dependencies of your project will be installed here when you run npm install -g yourproject
You can also find my blog post on interpreter management and PATH .