For Node.JS, where are the core modules in Win?

From the official api site it says that core modules are installed at the /lib folder of the root folder of NodeJS, but when I was trying to search for it I didn't see the /lib folder.

Any idea?

Additionally, after I've done a

var a = require("a.js");

is it possible to get the corresponding path to a.js?

that means /lib folder is in source code not your computer. you can see it in repository.

and

there are two patterns for require

  • absolute path: if the parameter is not started with ./' nor'../', it's absolute path. so node look for it in core module(it's compiled in node runtime) or `node_modules' that you installed locally using npm.

  • relative path: if the parameter is started with ./ or ../, it's relative path. so node look for it relative path to current position.

it's so simple. and you can use require.resolve('a.js') to get absolute system path. but core modules don't has path since it's built-in.

Although the accepted answer is good enough to resolve the question, it is worth mention that it has some misleading information regarding the patterns of required. From the very Reference Documentation of Node:

A module prefixed with '/' is an absolute path to the file. For example, require('/home/marco/foo.js') will load the file at /home/marco/foo.js.

A module prefixed with './' is relative to the file calling require(). That is, circle.js must be in the same directory as foo.js for require('./circle') to find it.

Without a leading '/' or './' to indicate a file, the module is either a "core module" or is loaded from a node_modules folder.