-m
您可以使用该选项将其他目录添加到 Ringo 的模块搜索路径。示例:underscore
通过 npm安装npm install underscore
并使用 启动 ringo ringo -m ./node_modules yourscript.js
。Undersocre 将可用,并且可以按预期要求:
const _ = require("underscore");
// logs --> "3,6,9"
console.log(_.map([1, 2, 3], function(num) {
return num * 3;
}));
您的具体问题似乎是 restify仅与 Node.js 兼容,而不与其他类似 CommonJS 的平台兼容。它可能有一些与 Ringo 兼容的子模块,但到目前为止我还没有找到。Ringo'spackage.json
与 Node's / npm's 不是 1:1 兼容package.json
。如果 restify 在包描述符中使用了一些特定于节点的东西,Ringo 就无法加载这些资源。
Ringo 的各种标准化模块仍然非常接近 CommonJS 背后的想法,而 Node 很久以前就离开了这条路。您在 Node 中找到了 CommonJS 模块(用于require()
加载模块),但没有找到 CommonJS 尝试为服务器端 JavaScript 建立的其他 API。
此外,Ringo 不是围绕回调/事件驱动的非阻塞 I/O 构建的。您可以在 Ringo 上使用非阻塞 I/O,但您也可以坚持使用阻塞 I/O。这与 Node.js 不同,您必须以非阻塞方式进行开发,并且一切都经过优化以使用事件驱动模型顺利运行。