Skip to content

Node compat: process.stdout.isTTY has only a getter #26123

Closed

Description

@csvn

Hello!

Background

In the vite package vite-plugin-checker, there is code that works in Node but fails in Deno v2.0.0. The error points to this line:

// /vite-plugin-checker/dist/esm/Checker.js:5:24
if (!(isMainThread || isInVitestEntryThread)) {
  process.stdout.isTTY = true;   // <---------------------
}

It seems that it's possible to set this property in Node, but in Deno the isTTY property is only a getter; thus the error. I feel like it's likely that the package's code is weird, but this still seems like a compatability issue vs running in Node.

Reproduction

  1. Create the following files:
    // index.html
    <html>
    <head>
      <meta charset="utf-8">
      <title>Example</title>
      <script type="module" src="index.ts"></script>
    </head>
    <body></body>
    </html>
    // index.ts
    console.log('hello');
    // package.json
    {
      "scripts": {
        "build": "vite build",
        "start": "vite"
      },
      "devDependencies": {
        "typescript": "^5.6.3",
        "vite": "^4.5.5",
        "vite-plugin-checker": "^0.8.0"
      }
    }
    // vite.config.mjs
    import { defineConfig } from 'vite';
    import { checker } from 'vite-plugin-checker';
    
    export default defineConfig({
      build: { outDir: './dist' },
      plugins: [checker({ typescript: true })]
    });
  2. Run deno install
  3. Run deno task build
  4. Program fails with error:
    error: Uncaught (in worker "") (in promise) TypeError: Cannot set property isTTY of #<Writable> which has only a getter
        at file:///[folder_path]/node_modules/.deno/vite-plugin- checker@0.8.0/node_modules/vite-plugin-checker/dist/esm/Checker.js:5:24
    

Suggestions

I'd be fine if a solution here was to add a set method, but just ignore the value to make the code work. But comparing what Node does when setting this property and doing the same would probably be a good idea.

Activity

  1. changed the title [-]Node compat: `process.stdout.isTTY` is not a setter[/-] [+]Node compat: `process.stdout.isTTY` has only a getter[/+] on Oct 10, 2024
  2. added
    bug
    on Oct 10, 2024
  3. csvn commented on Oct 12, 2024

    @csvn
    ContributorAuthor

    Thanks for the quick solution to this issue @marvinhagemeister 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugnode compat

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions