CNode

nodejs的require方法,console都是写在node.exe中的吗

Yyy030913发布于13 年前最后回复13 年前6 回复6595 浏览0 收藏

如题,require方法定义都找不到,唯一能找到的就是下面一行信息

this.require { [Function: require] resolve: [Function], main: undefined, extensions: { '.js': [Function], '.json': [Function], '.node': [Function] }, registerExtension: [Function], cache: {} } console对象,也没找到

查看回复

回复 (6)

Y
yy030913#1·13 年前
引用 jiyinyiyong系统内置函数, console 估计是 V8 代码里的.. require 没找到.. 代码 Github 有 https://github.com/joyent/node/tree/mast...

文档下载下来看了一天,还是没有头绪,太乱了,连个参考的说明都没有.........

J
jiyinyiyong#2·13 年前
引用 jiyinyiyong系统内置函数, console 估计是 V8 代码里的.. require 没找到.. 代码 Github 有 https://github.com/joyent/node/tree/mast...

@yy030913 语言内部实现不出现在文档感觉也挺正常的 你下载的是 Node 文档还是 JS 文档.? console 是 JS 里的内容, require 是 CommonJS 规范的内容, 另外 Node API 是 Node.. 反正都不在一个地方

L
lb1064#3·13 年前

#console定义 https://github.com/joyent/node/blob/master/src/node.js

  startup.globalConsole = function() {
    global.__defineGetter__('console', function() {
      return NativeModule.require('console');
    });
  };

#console实现 https://github.com/joyent/node/blob/master/lib/console.js

Y
yy030913#5·13 年前

exports.是导出方法吗?

J
jiyinyiyong#6·13 年前

系统内置函数, console 估计是 V8 代码里的.. require 没找到.. 代码 Github 有 https://github.com/joyent/node/tree/master/src

求助会 C++ 的同学..

参与回复
登录后即可参与回复。登录