新增于: v12.2.0
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const siblingModule = require('./sibling-module');
Added in: v12.2.0
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);
const siblingModule = require('./sibling-module');