deno.com

Usage in Deno

import * as mod from "node:module";

Classes #

Functions #

f
Module.createRequire
No documentation available
    f
    Module.enableCompileCache

    Enable module compile cache in the current Node.js instance.

      f
      Module.findPackageJSON
      No documentation available
        f
        Module.findSourceMap

        path is the resolved path for the file for which a corresponding source map should be fetched.

          f
          Module.flushCompileCache

          Flush the module compile cache accumulated from modules already loaded in the current Node.js instance to disk. This returns after all the flushing file system operations come to an end, no matter they succeed or not. If there are any errors, this will fail silently, since compile cache misses should not interfere with the actual operation of the application.

            f
            Module.getCompileCacheDir
            No documentation available
              f
              Module.isBuiltin
              No documentation available
                f
                Module.register

                Register a module that exports hooks that customize Node.js module resolution and loading behavior. See Customization hooks.

                  f
                  Module.runMain
                  No documentation available
                    f
                    Module.stripTypeScriptTypes

                    module.stripTypeScriptTypes() removes type annotations from TypeScript code. It can be used to strip type annotations from TypeScript code before running it with vm.runInContext() or vm.compileFunction(). By default, it will throw an error if the code contains TypeScript features that require transformation such as Enums, see type-stripping for more information. When mode is 'transform', it also transforms TypeScript features to JavaScript, see transform TypeScript features for more information. When mode is 'strip', source maps are not generated, because locations are preserved. If sourceMap is provided, when mode is 'strip', an error will be thrown.

                      f
                      Module.syncBuiltinESMExports

                      The module.syncBuiltinESMExports() method updates all the live bindings for builtin ES Modules to match the properties of the CommonJS exports. It does not add or remove exported names from the ES Modules.

                        f
                        Module.wrap
                        No documentation available

                          Interfaces #

                          Namespaces #

                          N
                          Module.constants
                          No documentation available
                            N
                            Module.constants.compileCacheStatus

                            The following constants are returned as the status field in the object returned by enableCompileCache to indicate the result of the attempt to enable the module compile cache.

                              Type Aliases #

                              T
                              Module.InitializeHook

                              The initialize hook provides a way to define a custom function that runs in the hooks thread when the hooks module is initialized. Initialization happens when the hooks module is registered via register.

                                T
                                Module.LoadHook

                                The load hook provides a way to define a custom method of determining how a URL should be interpreted, retrieved, and parsed. It is also in charge of validating the import attributes.

                                  T
                                  Module.ModuleFormat
                                  No documentation available
                                    T
                                    Module.ModuleSource
                                    No documentation available
                                      T
                                      Module.ResolveHook

                                      The resolve hook chain is responsible for telling Node.js where to find and how to cache a given import statement or expression, or require call. It can optionally return a format (such as 'module') as a hint to the load hook. If a format is specified, the load hook is ultimately responsible for providing the final format value (and it is free to ignore the hint provided by resolve); if resolve provides a format, a custom load hook is required even if only to pass the value to the Node.js default load hook.

                                        Variables #

                                        v
                                        __dirname

                                        The directory name of the current module. This is the same as the path.dirname() of the __filename.

                                          v
                                          __filename

                                          The file name of the current module. This is the current module file's absolute path with symlinks resolved.

                                            v
                                            exports

                                            The exports variable is available within a module's file-level scope, and is assigned the value of module.exports before the module is evaluated.

                                              v
                                              module

                                              A reference to the current module.

                                                v
                                                Module.builtinModules

                                                A list of the names of all modules provided by Node.js. Can be used to verify if a module is maintained by a third party or not.

                                                  v
                                                  Module.constants.compileCacheStatus.ALREADY_ENABLED

                                                  The compile cache has already been enabled before, either by a previous call to enableCompileCache, or by the NODE_COMPILE_CACHE=dir environment variable. The directory used to store the compile cache will be returned in the directory field in the returned object.

                                                    v
                                                    Module.constants.compileCacheStatus.DISABLED

                                                    Node.js cannot enable the compile cache because the environment variable NODE_DISABLE_COMPILE_CACHE=1 has been set.

                                                      v
                                                      Module.constants.compileCacheStatus.ENABLED

                                                      Node.js has enabled the compile cache successfully. The directory used to store the compile cache will be returned in the directory field in the returned object.

                                                        v
                                                        Module.constants.compileCacheStatus.FAILED

                                                        Node.js fails to enable the compile cache. This can be caused by the lack of permission to use the specified directory, or various kinds of file system errors. The detail of the failure will be returned in the message field in the returned object.

                                                          v
                                                          require
                                                          No documentation available