TypeError: Object.setPrototypeOf called on null or undefined
<p>I have a Node.js project in which I have my own custom error:</p>

<pre><code>'use strict';

require('util').inherits(module.exports, Error);

function CustomError(message, extra) {
  Error.captureStackTrace(this, this.constructor);
  this.name = this.constructor.name;
  this.type = 'CustomError';
  this.message = message;
  this.extra = extra;
};

module.exports = CustomError;
</code></pre>

<p>This used to work fine. I could <code>Throw new CustomError('my message', dataObject)</code> and capture that error independently of offer error types and control the program flow accordingly. </p>

<p>However, since updating Node to the latest stable release (v6.4.0) it's now broken. When I run my unit tests I get the error:</p>

<pre><code>TypeError: Object.setPrototypeOf called on null or undefined
    at Function.setPrototypeOf (native)
    at Object.exports.inherits (util.js:973:10)
    at Object.&lt;anonymous&gt; (CustomError.js:3:17)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)
    at Module.require (module.js:483:17)
    at require (internal/module.js:20:19)
</code></pre>