YumYumYum YumYumYum - 9 months ago 203
Node.js Question

Nodejs - DeprecationWarning process.EventEmitter is deprecated

Already applied require('events') but still the warning is keep showing, what is that i am doing wrong here? Why

is keep showing up even its not used?

Node v6.7.0 it works, but v6.9.1 this is happening on CentOS 7.2

var pro = require('events');
var port = parseInt(config.server.port, 10);
var io = require('socket.io').listen(port); // This line is causing it???

Output Warning:

dev environment detected
info - socket.io started
(node:32708) DeprecationWarning: process.EventEmitter is deprecated. Use require('events') instead.


I used
$ npm install

where package.json had following:

"name": "TEST",
"description": "TEST",
"version": "0.0.2",
"dependencies": {
"getconfig": "0.3.0",
"node-uuid": "1.2.0",
"socket.io": "0.9.16",
"yetify": "0.0.1"
"main": "test.js",
"repository": {
"type": "git",
"devDependencies": {
"socket.io-client": "0.9.16",
"precommit-hook": "0.3.10",
"tape": "^2.13.1"
"scripts": {
"test": "node test.js"

rsp rsp
Answer Source

You may be using and old version of socket.io because in your code you don't use process.EventEmitter directly. If this program that you posted shows the warning then this is what could be the problem.

On my system the same program doesn't cause the problem - node 7.0.0 and socket.io 1.5.1 - but maybe you didn't include all of your code in your example (e.g. the config.server.port is not defined so you seem to have removed some portions of your code that may be relevant here).

You can see the version that you're using in:


See your own package.json and search for a line like:

"socket.io": "^1.4.8"

(like this line in one of my projects on GitHub) to see what version is installed with npm install and update the version if it's outdated. It's also possible that you have the socket.io module installed globally.

You can use David to let you know that you have outdated dependencies.

You can use Greenkeeper to help you keep your dependencies up to date.

(It's also good to add Snyk to let you know about vulnerabilities in your dependencies.)


You posted your package.json and indeed you use an old version of socket.io:

"socket.io": "0.9.16",

so this exact version is installed when you run npm install. The current version is 1.5.1 - see:

You can change the version and rerun npm install. If the code is exactly the same as posted then you shouldn't need to change your code. If there is more code then see http://socket.io/docs/migrating-from-0-9/ for things that may need to be changed.

If you use CI tests, David and Greenkeeper, as I suggest above, then all of that (updating the version, testing if it still works etc.) would basically be done for you automatically.

If you use Snyk, as I also suggest above, then you'll know the version of socket.io that you're using has high-severity vulnerabilities, including Denial of Service and Remote Memory Exposure - that you now have in your code. See:

So as you can see, updating the socket.io dependency is important for more serious reasons than just the deprecation warning.