Skip to content

bug: TypeError [ERR_INVALID_ARG_TYPE] on renderTitle due to broken figlet compilation ({}.url) #617

Description

@Riczer

Describe the bug

When running npx create-expo-stack@latest on Node v20+, the CLI crashes instantly during the renderTitle phase with a TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of URL. Received undefined.

To Reproduce

Run the CLI in a clean Linux environment using Node v20.20.2+ and npm 10.8.2+:
npx create-expo-stack@latest

Expected behavior

The CLI should boot up and render the ASCII title smoothly.

Error Stack Trace

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of URL. Received undefined
    at fileURLToPath (node:internal/url:1487:11)
    at Object.<anonymous> (.../node_modules/figlet/dist/node-figlet.cjs:29:53)
    at Object.<anonymous> (.../node_modules/create-expo-stack/build/utilities/renderTitle.js:16:34)

Additional Context & Diagnosis

I deep-dived into the compiled node-figlet.cjs file generated inside the package. Around line 29, the bundler translated import.meta.url into an empty inline object property lookup:

var __filename$1 = (0, require("url").fileURLToPath)({}.url);

Since ({}.url) mathematically evaluates to undefined, modern strict Node.js environments immediately throw a fatal TypeError when passed to fileURLToPath.

Hot-fix verified: Changing that line to use the classic CommonJS global __filename fixes the issue completely:

var __filename$1 = __filename;

The bundler configuration needs to be adjusted so it doesn't leak empty import_meta polyfills into CJS builds.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions