views:

37

answers:

2

In Node.js I can use a module like this:

sys = require("sys");

How do I create my own module like "sys" so that I can require it from other files?

+1  A: 

You probably want to look into CommonJS http://www.commonjs.org/. Node follows this protocol for require(). Some of the documentation on CommonJS describes projects that implement this in the browser.

Geuis
I have looked into that site but I don't get the purpose of it. It provides modules I can use? If so, where are the modules and the API documentation? And where is the documentation for require()?
never_had_a_name
Try this, http://github.com/azer/jsbuild
Geuis
+1  A: 

The API contains an example of writing your own module: http://nodejs.org/api.html#modules-312

dhofstet