Especificación de Ficheros Conteniendo Módulos

  1. If the exact filename is not found, then node will attempt to load the required filename with the added extension of .js, .json, and then .node.

  2. .js files are interpreted as JavaScript text files, and .json files are parsed as JSON text files. .node files are interpreted as compiled addon modules

  3. 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.

  4. A module prefixed with './' is relative to the file calling require().

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

  6. If the given path does not exist, require() will throw an Error with its code property set to MODULE_NOT_FOUND.

Casiano Rodriguez León 2015-06-18