开发者

Creating modules to be required in other files in Javascript?

开发者 https://www.devze.com 2023-01-19 06:18 出处:网络
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?The API contains an example of w

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?


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消