Already applied require('events') but still the warning is keep showing, what is that i am doing wrong here? Why
var pro = require('events');
var port = parseInt(config.server.port, 10);
var io = require('socket.io').listen(port); // This line is causing it???
dev environment detected
info - socket.io started
(node:32708) DeprecationWarning: process.EventEmitter is deprecated. Use require('events') instead.
$ npm install
"test": "node test.js"
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:
(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:
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.