Node.js Manual & DocumentationSynopsis 概要 Global Objects 全局对象 o global o process o require() o require.resolve() o require.paths o __filename o __dirname o module Timers 定时器 o setTimeout(callback, delay, [arg] o Loading from the `require.paths` Folders 从`require.paths`目 录中加载 Note:** Please Avoid Modifying `require.paths` **注意:** 请不要修改`requires.paths` Setting `require.paths` to some other value does does nothing. 将`require.paths`设为其他值不会产生任何作用 Putting relative paths in `require.paths` is... weird. 不建议在`require.paths`中发入相对路径 Zero Isolation 零隔离 Addenda: Package Manager Tips 附录:包管理技巧0 码力 | 153 页 | 1.21 MB | 1 年前3
NodeJS 中文文档 V0.2.3模块”这一节。 require.paths require.paths require.paths require.paths 一个保存了 require 函数搜索路径的数组。你可以修改此数组添加自定义路径。 例子:在搜索路径列表开头添加一个路径。 require.paths.unshift('/usr/local/node'); console.log(require.paths); // /usr/local/node /'前缀加载的模块必须和加载模块的文件位于同一文件夹下,所以将 circle.js 和 foo.js 放在同一目录下。 如果不用'./'前缀,比如 require('assert'),那么则会在 require.paths 数组指定的路径下寻找,require.paths 在我的机 器上输出如下: [ '/home/ryan/.node_libraries' ] [ '/home/ryan/.node_libraries' ] index.node 有'.node'后缀的模块是 Node 系统的二进制模块:可以参考'Addons'来得到更多信息。'index.js'允许我们把一个模块 作为一个目录打包。 require.paths 可以在运行时修改或者在类 UNIX 系统下通过修改 NODE_PATH 环境变量来达到同样的目的。 最新版文档:wiki.grati.org QQ 群:53090214 共同学习 NodeJS,欢迎加入。0 码力 | 62 页 | 542.14 KB | 1 年前3
共 2 条
- 1













