unjs / consola

🐨 Elegant Console Logger for Node.js and Browser
Other
6k stars 175 forks source link

Segmentation Fault 11 when packaging consola with Vercel pkg #261

Open slowkoder opened 10 months ago

slowkoder commented 10 months ago

Environment

Reproduction

  1. Install pkg and consola NPM packages
  2. Create JS file with the following:
    // index.cjs
    const {consola} = require('consola');
    consola.info('This is info!');
  3. Package into CLI executable using pkg
    # Via terminal
    npx pkg "./index.cjs" -t "node16-macos" -o app
  4. Run the application
    ./app
  5. Error is displayed
    Segmentation fault: 11

Describe the bug

When trying to package consola using vercel pkg I get the following error:

Segmentation fault: 11

See Reproduction for steps to replicate

Additional context

No response

Logs

No response

septatrix commented 7 months ago

I fell into this rabbit hole today. If vercel happens to compile their nodejs runtime with --with-intl=small-icu then this might actually be a bug in nodejs itself which I just filed: https://github.com/nodejs/node/issues/51752 This package could implement a workaround but I do not know of a good method to correctly test the level of ICU support, and if there were, it should likely be implemented in string-width itself so that everyone benefits.