5

When I run the following code in node:

var shell = require('shelljs');
var files = shell.ls('-R', './**/foobar');
console.log('Files found:\n' + files.join('\n'));

I see this in the output:

ls: no such file or directory: ./**/foobar

How can I suppress the stderr, keep it from being shown?

1 Answer 1

7

Took me a bit to figure this out, but you need to configure shelljs to be silent, like so:

var shell = require('shelljs');
shell.config.silent = true;

From the README, this:

Suppresses all command output if true, except for echo() calls. Default is false.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, this works. Passing {silent: true} to exec() doesn't seem to be enough.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.