$ npm install tshy-after
Auto set package.json after tshy run
typesSet package.types to package.exports['.'].require.types
import.meta.url and import.meta.resolve SyntaxError on CJSSyntaxError: Cannot use 'import.meta' outside a module
e.g.: Get the file's dirname
// src/index.ts
import { fileURLToPath } from 'node:url';
import path from 'node:path';
export function getDirname() {
if (typeof __dirname !== 'undefined') {
return __dirname;
}
// @ts-ignore
return path.dirname(fileURLToPath(import.meta.url));
}
Made with contributors-img.
© 2010 - cnpmjs.org x YWFE | Home | YWFE