Skip to content

compat: chalk doesn't work because of missing __proto__ #13321

@bartlomieju

Description

@bartlomieju

index.js

const chalk = require('chalk')

const test = {
    name: "foo",
};
const p = "*";
console.log(chalk.bold);
const pref = chalk.bold.dim(test.name + p + ' ')
console.log("pref", pref);

package.json

{
  "name": "test_chalk",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "chalk": "^3.0.0"
  }
}
$ node index.js
[Function: builder] {
  _generator: [Function (anonymous)] Chalk {
    constructor: [Function (anonymous)],
    Instance: [class ChalkClass],
    supportsColor: { level: 3, hasBasic: true, has256: true, has16m: true },
    stderr: [Function (anonymous)] Chalk {
      constructor: [Function (anonymous)],
      Instance: [class ChalkClass],
      supportsColor: [Object]
    },
    Level: {
      '0': 'None',
      '1': 'Basic',
      '2': 'Ansi256',
      '3': 'TrueColor',
      None: 0,
      Basic: 1,
      Ansi256: 2,
      TrueColor: 3
    }
  },
  _styler: {
    open: '\x1B[1m',
    close: '\x1B[22m',
    openAll: '\x1B[1m',
    closeAll: '\x1B[22m',
    parent: undefined
  },
  _isEmpty: undefined
}
pref foo*
$ deno run --unstable --compat --no-check index.js
[Function: builder] {
  __proto__: [Function] { level: [Getter/Setter] },
  _generator: [Chalk] {
    constructor: [Function],
    Instance: [Function: ChalkClass],
    supportsColor: { level: 3, hasBasic: true, has256: true, has16m: true },
    stderr: [Chalk] {
      constructor: [Function],
      Instance: [Function: ChalkClass],
      supportsColor: { level: 3, hasBasic: true, has256: true, has16m: true }
    },
    Level: {
      "0": "None",
      "1": "Basic",
      "2": "Ansi256",
      "3": "TrueColor",
      None: 0,
      Basic: 1,
      Ansi256: 2,
      TrueColor: 3
    }
  },
  _styler: {
    open: "\x1b[1m",
    close: "\x1b[22m",
    openAll: "\x1b[1m",
    closeAll: "\x1b[22m",
    parent: undefined
  },
  _isEmpty: undefined
}
error: Uncaught (in promise) TypeError: chalk.bold.dim is not a function
const pref = chalk.bold.dim(test.name + p + ' ')
                        ^
    at Object.<anonymous> (file:///Users/biwanczuk/dev/test_chalk/index.js:8:25)
    at Module._compile (https://deno.land/[email protected]/node/module.ts:252:36)
    at Object.Module._extensions..js (https://deno.land/[email protected]/node/module.ts:1276:10)
    at Module.load (https://deno.land/[email protected]/node/module.ts:231:33)
    at Function._load (https://deno.land/[email protected]/node/module.ts:540:14)
    at loadCjsModule ([deno:cli/compat/mod.rs:116:30]:3:22)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions