简体   繁体   English

如何从一个node.js模块导出多个“子模块”?

[英]How do I export multiple 'sub-modules' from one node.js module?

Here's what I mean by exporting 'sub-modules': 这就是我导出“子模块”的意思:

var fibers = require('fibers');         // this works, it's the 'main' module
var future = require('fibers/future');  // this also works, it's a 'sub'-module

How would I do this 'abc/xyz' export? 我将如何导出“ abc / xyz”? I've gone through the fibers source code a little bit, and it doesn't seem like this is something that node/npm will do for me. 我已经阅读了一些fibers源代码,似乎这不是node / npm为我做的事情。

It represents an actual filesystem path. 它代表实际的文件系统路径。 So, in the root directory of your abc module, call a file xyz.js or xyz.json , or create an xyz/ directory with an index.js . 因此,在abc模块的根目录中,调用文件xyz.jsxyz.json ,或使用index.js创建一个xyz/目录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM