2016-11-22 13 views
0

にアップデートした後、私はNPMを更新しましたし、今私のコードは、(写真を参照してください)以下のエラーを返して:持つEventEmitterエラーNPM 3.10

Error Message誰かが犯人を特定のガイダンスを提供してくださいできますか?私の疑念は、それが私が慣れていない継承と関係しているということです。

/** 
* Expose the constructor. 
*/ 

exports = module.exports = Store; 

/** 
* Module dependencies. 
*/ 

var EventEmitter = process.EventEmitter; 

/** 
* Store interface 
* 
* @api public 
*/ 

function Store (options) { 
    this.options = options; 
    this.clients = {}; 
}; 

/** 
* Inherit from EventEmitter. 
*/ 

Store.prototype.__proto__ = EventEmitter.prototype; 

/** 
* Initializes a client store 
* 
* @param {String} id 
* @api public 
*/ 

Store.prototype.client = function (id) { 
    if (!this.clients[id]) { 
    this.clients[id] = new (this.constructor.Client)(this, id); 
    } 

    return this.clients[id]; 
}; 

/** 
* Destroys a client 
* 
* @api {String} sid 
* @param {Number} number of seconds to expire client data 
* @api private 
*/ 

Store.prototype.destroyClient = function (id, expiration) { 
    if (this.clients[id]) { 
    this.clients[id].destroy(expiration); 
    delete this.clients[id]; 
    } 

    return this; 
}; 

/** 
* Destroys the store 
* 
* @param {Number} number of seconds to expire client data 
* @api private 
*/ 

Store.prototype.destroy = function (clientExpiration) { 
    var keys = Object.keys(this.clients) 
    , count = keys.length; 

    for (var i = 0, l = count; i < l; i++) { 
    this.destroyClient(keys[i], clientExpiration); 
    } 

    this.clients = {}; 

    return this; 
}; 

/** 
* Client. 
* 
* @api public 
*/ 

Store.Client = function (store, id) { 
    this.store = store; 
    this.id = id; 
}; 
+0

廃止予定の警告も表示されませんでしたが、_ "process.EventEmitterは廃止予定です。代わりにrequire( 'events')を使用してください。 – robertklep

+0

警告はありません、指導をいただきありがとうございます。 – user2832956

答えて

0

持つEventEmitterクラスを取得するための現在の方法は、次のとおりです。

const EventEmitter = require('events'); 

あなたはprocess.EventEmitterを使用すべきではありません。


また、オブジェクトをサブクラス化する近代的な方法は、ES6 class構文または__proto__を使用していない、Object.create()を使用してのいずれかを使用しています。

+0

ガイダンスをいただきありがとうございました問題を解決することができました。 :) – user2832956

+0

@ user2832956 - ここでは新しいかもしれないので、この回答があなたの問題を解決するのに役立つならば、答えの左側にある緑色のチェックマークをクリックすることで、 。これはまた、適切な手順に従うためにサイト上でいくつかの評判ポイントを得るでしょう。 – jfriend00

関連する問題