Skip to main content

require package

Functions

FunctionDescription
getRequireExtensions()Returns file extensions which can be imported.
importPath(path)Imports a module from the specified path. This function supports both CommonJS and ECMAScript modules. When a CommonJS module is imported, its module.export is assigned to default in order to match the behavior of ECMAScript modules.
isESMSupported()Returns true if ECMAScript modules are supported in the current environment. If ESM_IMPORT_DISABLED=true environment variable is set, this function will always return false.
requireDefault(path)Imports a module from the specified path and returns its default export. This function is only compatible with CommonJS modules.
resolve(id, options)Resolves path to the specified module. Throws MODULE_NOT_FOUND error when the given path can't be resolved to a module.
resolveESM(id, options)Resolves path to the specified module. Returns ECMAScript module path when available.

Interfaces

InterfaceDescription
ResolveOptions