@nestjs/cli
Version:
Nest - modern, fast, powerful node.js web framework (@cli)
16 lines (15 loc) • 471 B
JavaScript
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
/**
* Resolves `path` through Node's module resolution, returning the resolved
* filename or `undefined` when it cannot be found. Callers need the resolved
* path itself (to decide how to load the file), not merely whether it exists.
*/
export function resolveModulePath(path) {
try {
return require.resolve(path);
}
catch {
return undefined;
}
}