module.createRequire(filename)


    • filename <string> | <URL> Filename to be used to construct the require function. Must be a file URL object, file URL string, or absolute path string.
    • Returns: <require> Require function
    import { createRequire } from 'node:module';
    const require = createRequire(import.meta.url);
    
    // sibling-module.js is a CommonJS module.
    const siblingModule = require('./sibling-module');