Package to replace
desm
Suggested replacement(s)
Node >=20, Deno, Bun:
- import { join } from 'desm';
+ import { join } from 'node:path';
- desm('./foo.ts');
+ join(import.meta.dirname, './foo.ts');
- import { dirname } from 'desm'; // or import desm from 'desm'
- dirname(import.meta.url);
+ import.meta.dirname;
- import { filename } from 'desm';
- filename(import.meta.url);
+ import.meta.filename;
Node <=20:
- import { join } from 'desm';
+ import { dirname, join } from 'node:path';
+ import { fileURLToPath } from 'node:url';
- desm('./foo.ts');
+ join(dirname(fileURLToPath(import.meta.url)), './foo.ts');
- import { dirname } from 'desm'; // or import desm from 'desm'
+ import { dirname } from 'node:path';
+ import { fileURLToPath } from 'node:url';
- dirname(import.meta.url);
+ dirname(fileURLToPath(import.meta.url));
- import { filename } from 'desm';
+ import { fileURLToPath } from 'node:url';
- filename(import.meta.url)l
+ fileURLToPath(import.meta.url);
You can also do something like
new URL("./foo.ts", import.meta.url).pathname;
Manifest type
native (replaceable by a built-in platform feature)
Rationale
micro utility to avoid fairly simple syntax historically, but now we have even smaller way of doing it
Availability
import.meta.dirname/filename added in Node v20.11.0,
Code example (optional)
Package to replace
desm
Suggested replacement(s)
Node >=20, Deno, Bun:
Node <=20:
You can also do something like
Manifest type
native (replaceable by a built-in platform feature)
Rationale
micro utility to avoid fairly simple syntax historically, but now we have even smaller way of doing it
Availability
import.meta.dirname/filenameadded in Node v20.11.0,Code example (optional)