Skip to content

Cannot read toString of null when using execSync #415

@jordan-thoms

Description

@jordan-thoms

I've been occasionally getting the following error:

/private/var/folders/md/b4my_5v94kbcjzbdhs711fnr0000gn/T/shelljs_64464d02b4682598b994:4
  fs.writeFileSync('/var/folders/md/b4my_5v94kbcjzbdhs711fnr0000gn/T/shelljs_7bf01b37f53810b840b5', err ? err.code.toString() : '0');
                                                                                                                  ^

TypeError: Cannot read property 'toString' of null
    at /private/var/folders/md/b4my_5v94kbcjzbdhs711fnr0000gn/T/shelljs_64464d02b4682598b994:4:115
    at ChildProcess.exithandler (child_process.js:220:5)
    at emitTwo (events.js:87:13)
    at ChildProcess.emit (events.js:172:7)
    at maybeClose (internal/child_process.js:827:16)
    at Socket.<anonymous> (internal/child_process.js:319:11)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at Pipe._onclose (net.js:475:12)
shell.js: internal error
Error: Command failed: "/usr/local/Cellar/node4-lts/4.4.0/bin/node" /var/folders/md/b4my_5v94kbcjzbdhs711fnr0000gn/T/shelljs_64464d02b4682598b994
    at checkExecSyncError (child_process.js:464:13)
    at Object.execSync (child_process.js:504:13)
    at execSync (/../shelljs/src/exec.js:81:11)

This seems to be caused by the code generated in https://github.com/shelljs/shelljs/blob/master/src/exec.js#L72 - it seems that node now returns an Error object when exec fails, which does not have a 'code' property.

This is with node v4.4.0 on OSX 10.11.3.

Metadata

Metadata

Assignees

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