Skip to content

consuming spawn UV_EACCES errors #1769

@TrevTheDev

Description

@TrevTheDev
  • Node.js Version: 11.9.0
  • OS: linux
  • Scope (install, code, runtime, meta, other?):
  • Module (and version) (if relevant):child_process.js

How should one consume UV_EACCES errors raised using spawn?

Assuming code like this:

const { spawn } = require('child_process');
const ls = spawn('ls', ['-lh', '/usr'],{cwd: '/dir/that/has/permissions/set/to666});

//next line throws an error because stdout does not exist due to UV_EACCES  error:
ls.stdout.on('data', (data) => {
  console.log(`stdout: ${data}`);
});

ls has an error event, but how should I access this before ls.stdout throws an error?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions