{ } qjs-modules

module

Source: lib/module.js (pure JS)

Node's node:module (https://nodejs.org/api/module.html). `import ... from 'node:module' resolves here too (lib/loaders/node.jsmaps a leadingnode:` to the bare name). The default export is the Module class, with every named export as a static.

Exports

ExportDescription
Modulethe CommonJS module class: new Module(id, parent), load(), require(), _compile(), parent, isPreloading
builtinModulessorted builtin names, with Node's subpaths (fs/promises, timers/promises, readline/promises)
isBuiltin(name)with or without node:
createRequire(filename)a require() for a path, file:// URL string or URL; backed by the require builtin
registerHooks(hooks)the qjsm global of the same name (undefined on other engines), see doc/qjsm.md
findPackageJSON(specifier, base)closest package.json of a relative/absolute specifier, or the package root's for a bare one; undefined if none
runMain(main)loads main as the entry module
constants{ compileCacheStatus }
globalPathsNODE_PATH, ~/.node_modules, ~/.node_libraries, <prefix>/lib/node
SourceMapa Source Map v3: payload, lineLengths, findEntry(), findOrigin()
findSourceMap(path)the map named by a file's //# sourceMappingURL= (data: URL or path), once setSourceMapsSupport(true)
getSourceMapsSupport(), setSourceMapsSupport(enabled, options)the flags are recorded; no stack trace uses them
stripTypeScriptTypes(code, options)mode: 'strip' only; runs the external swc CLI, throws ERR_FEATURE_UNAVAILABLE without it

The internals Node exposes on Module are there too: _cache, _pathCache, _extensions (.js, .json, .node), _load, _resolveFilename, _resolveLookupPaths, _findPath, _nodeModulePaths, _initPaths, _preloadModules, _debug (NODE_DEBUG=module), _stat, _readPackage, wrap, wrapper.

Differences from Node

ExportHere
register()throws ERR_FEATURE_UNAVAILABLE; use registerHooks()
syncBuiltinESMExports()no-op; builtin namespaces are the module exports themselves
enableCompileCache()returns { status: FAILED, message }; getCompileCacheDir() is undefined, flushCompileCache() a no-op
.node extensionthrows ERR_DLOPEN_FAILED
findPackageJSON()returns undefined for a missing package (Node 22 throws)
createRequire()resolves with lib/require.js, not Module._load()

qjsm build information (not in Node)

Present on qjsm; Module.buildInfo is undefined on other runtimes.

ExportReturns
buildInfothe info blob baked into qjsm (same as qjsm --build-info)
layout()compiled-in prefix, native/JS/data dirs and the effective search path (QUICKJS_MODULE_PATH applied)
builtins()[{name, kind: 'native' | 'js', size?}], size = bytes of bytecode
bytecode(name)ArrayBuffer copy of a JS builtin's bytecode; null for a native one; undefined if unknown
installed()[{name, kind, path, shadowed}] found on the search path
manifest()the installed share/qjsm/manifest.json, or null
verify()differences between binary, manifest and disk (empty array: all agree)

Export list

Generated by utilities/doc-api.js from the module dump of utilities/api-surface.sh: 217 members. Edit the text above this block, not the block.

Functions: _debug(), _findPath(), _initPaths(), _load(), _nodeModulePaths(), _preloadModules(), _resolveFilename(), _resolveLookupPaths(), builtins(), bytecode(), createRequire(), enableCompileCache(), findPackageJSON(), findSourceMap(), flushCompileCache(), getCompileCacheDir(), getSourceMapsSupport(), installed(), isBuiltin(), layout(), manifest(), register(), registerHooks(), runMain(), setSourceMapsSupport(), stripTypeScriptTypes(), syncBuiltinESMExports(), verify()

Values: _cache, _pathCache

Module

class, constructible

  • static methods: Module(), SourceMap(), _debug(), _findPath(), _initPaths(), _load(), _nodeModulePaths(), _preloadModules(), _readPackage(), _resolveFilename(), _resolveLookupPaths(), _stat(), builtins(), bytecode(), createRequire(), enableCompileCache(), findPackageJSON(), findSourceMap(), flushCompileCache(), getCompileCacheDir(), getSourceMapsSupport(), installed(), isBuiltin(), layout(), manifest(), register(), registerHooks(), runMain(), setSourceMapsSupport(), stripTypeScriptTypes(), syncBuiltinESMExports(), verify(), wrap()
  • static values: _cache, _extensions, _pathCache, buildInfo, builtinModules, constants, globalPaths, wrapper
  • methods: _compile(), load(), require()
  • properties: isPreloading (get), parent (get/set)

SourceMap

class, constructible

  • methods: findEntry(), findOrigin()
  • properties: lineLengths (get), payload (get)

_extensions

object

  • static methods: '.js'(), '.json'(), '.node'()

buildInfo

object

  • static values: buildType, builtin, bytecode = 5, compiler, layout, qjsc, qjsm, quickjs, target

builtinModules

object

  • static values: '0', '1', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '2', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '3', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '4', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '5', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59', '6', '60', '61', '7', '8', '9', length = 62

default

class, constructible

  • static methods: Module(), SourceMap(), _debug(), _findPath(), _initPaths(), _load(), _nodeModulePaths(), _preloadModules(), _readPackage(), _resolveFilename(), _resolveLookupPaths(), _stat(), builtins(), bytecode(), createRequire(), enableCompileCache(), findPackageJSON(), findSourceMap(), flushCompileCache(), getCompileCacheDir(), getSourceMapsSupport(), installed(), isBuiltin(), layout(), manifest(), register(), registerHooks(), runMain(), setSourceMapsSupport(), stripTypeScriptTypes(), syncBuiltinESMExports(), verify(), wrap()
  • static values: _cache, _extensions, _pathCache, buildInfo, builtinModules, constants, globalPaths, wrapper
  • methods: _compile(), load(), require()
  • properties: isPreloading (get), parent (get/set)

constants

object

  • static values: compileCacheStatus

globalPaths

object

  • static values: '0', '1', '2', length = 3