2016-11-22 4 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

deprecation 경고도 표시되지 않았으므로 _ "process.EventEmitter는 더 이상 사용되지 않습니다. 대신 require ('events')를 사용하십시오."_? – robertklep

+0

경고가 없으므로 안내해 주셔서 감사합니다. – user2832956

답변

0

EventEmitter 클래스를 얻을 수있는 현재의 방법은 : 당신은 process.EventEmitter를 사용해서는 안

const EventEmitter = require('events'); 

.


또한 오브젝트를 서브하는 방법은 현대 ES6 class 구문 또는 __proto__를 사용하지 Object.create()를 사용 하나를 사용한다.

+0

지도 주셔서 감사합니다 문제를 해결할 수있었습니다. :) – user2832956

+0

@ user2832956 - 당신이이 새로운 대답 일지 모르지만이 답변을 통해 문제를 해결할 수 있다면 답변의 왼쪽에있는 녹색 체크 표시를 클릭하여이 답변을 수락 된 답변으로 표시하여 커뮤니티에 표시 할 수 있습니다 . 이것은 또한 적절한 절차를 따르기 위해 사이트에서 평판 포인트를 얻게됩니다. – jfriend00