{ } qjs-modules

require

Source: lib/require.js (pure JS) — default export: require

A CommonJS-style require() for loading modules synchronously.

Exports

ExportArgsKindDescription
require(m)1functionResolves and loads module m, returning its exports (or exports.default). (default export)

Resolution

mResult
./x, ../x, /xthe file, relative to the caller
node:fs, fs, util, fs/promises, ... (Node's names)Node's module object, the same as import('node:fs')'s default
another bare namethe nearest node_modules/m above the caller (package.json main, then index.js), else a qjsm builtin or QUICKJS_MODULE_PATH

An error thrown while loading m reaches the caller unchanged; only a SyntaxError makes it retry m as an ES module.

Export list

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

Functions: default(), require()