util.inherits抛出TypeError:无法读取undefined的属性'prototype'

Hyd*_*erA 3 inheritance node.js

app.js

var Website = new require( './jslib/website.js' );
Run Code Online (Sandbox Code Playgroud)

./jslib/website.js

var util = require('util'),
    events = require('events');

module.exports = Website;
function Website()
{
    events.EventEmitter.call( this );
    return this;
}
util.inherits( Website, events.EventEmiter );
Run Code Online (Sandbox Code Playgroud)

控制台输出

PATH_TO_APPDIR>node app.js

util.js:538
  ctor.prototype = Object.create(superCtor.prototype, {
                                          ^
TypeError: Cannot read property 'prototype' of undefined
    at Object.exports.inherits (util.js:538:43)
    at Object.<anonymous> (PATH_TO_APPDIR\jslib\website.js:9:6)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:362:17)
    at new require (module.js:378:17)
    at Object.<anonymous> (PATH_TO_APPDIR\app.js:1:16)
    at Module._compile (module.js:449:26)
Run Code Online (Sandbox Code Playgroud)

这是Windows 7*上的NodeJS 8.22

Dea*_*ady 9

您的代码中有拼写错误.

util.inherits( Website, events.EventEmiter );
Run Code Online (Sandbox Code Playgroud)

应该

util.inherits( Website, events.EventEmitter );
Run Code Online (Sandbox Code Playgroud)