Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work in a forked child process #253

Open
nodesocket opened this issue Mar 27, 2019 · 1 comment
Open

Does not work in a forked child process #253

nodesocket opened this issue Mar 27, 2019 · 1 comment

Comments

@nodesocket
Copy link

When a child processes is forked:

const cp = require('child_process');
cp.fork('./worker.js');
// worker.js
const colors = require('colors');
console.log(colors.red('this should be red...'));

Colors does not seem to work inside the forked child (i.e. worker.js).

@mrjacobbloom
Copy link
Contributor

I just ran into something similar running a script in a cron job. It turns out that the package tries to detect whether the console supports colors, and you can override it but it's not documented. This worked for me:

const colors = require('colors');
colors.enable();

It looks like you can also set process.env.FORCE_COLOR=1 or use any one of a bunch of flags to force colors to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants