Skip to main content
Module

std/node/module.ts>default

Deno standard library
Go to Latest
class default
import { default } from "https://deno.land/std@0.166.0/node/module.ts";

Constructors

new
default(id?, parent?: Module | null)

Properties

children: Module[]
exports: any
filename: string | null
id: string
loaded: boolean
parent: Module | null
path: string
paths: string[]

Methods

_compile(content: string, filename: string): any
load(filename: string)
require(id: string): any

Static Properties

_cache: { [key: string]: Module; }
_extensions: { [key: string]: (module: Module, filename: string) => any; }
_pathCache
builtinModules: string[]
globalPaths: string[]
wrapper: string[]

Static Methods

_findPath(
request: string,
paths: string[],
isMain: boolean,
): string | boolean
_load(
request: string,
parent: Module,
isMain: boolean,
): any
_nodeModulePaths(from: string): string[]
_preloadModules(requests: string[])
_resolveFilename(
request: string,
parent: Module,
isMain: boolean,
options?: { paths: string[]; },
): string
_resolveLookupPaths(request: string, parent: Module | null): string[] | null
createRequire(filename: string | URL): RequireFunction

Create a require function that can be used to import CJS modules. Follows CommonJS resolution similar to that of Node.js, with node_modules lookup and index.js lookup support. Also injects available Node.js builtin module polyfills.

    import { createRequire } from "https://deno.land/std@0.166.0/node/module.ts";
    const require = createRequire(import.meta.url);
    const fs = require("fs");
    const leftPad = require("left-pad");
    const cjsModule = require("./cjs_mod");
wrap(script: string): string