【发布时间】:2012-08-14 08:00:48
【问题描述】:
假设我已经运行了以下代码:
var toType = function(obj){
return ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase();
};
var someModule = require("./path/to/name");
console.log(toType(require.cache["./path/to/name"]));
someModule();
在位置 ./path/to/name.js 我有以下代码:
module.exports = function (){
console.log("Hell World!");
};
这两个 sn-ps 没有运行,所以我想我在这里遗漏了一些东西。输出如下:
node: no process found
undefined
Hell World!
[Finished in 0.1s]
-
require("./path/to/name");是如何映射到require.cache;的? - 如何检索模块、删除它并检查它的类型?
将不胜感激带有代码的答案。
【问题讨论】: