user6554563 user6554563 - 1 year ago 231
Javascript Question

In nodeJs on method is unresolved in webstorm

I am learning in node and i have installed the module using-

npm install --save

here is my code

var app = require('express')();
var http = require('http').Server(app);
var io = require('')(http);

app.get('/', function(req, res){

io.on('connection', function(socket){
console.log('a user connected');

http.listen(3000, function(){
console.log('listening on *:3000');

enter image description here

but webstorm is saying that 'on' is unresolved .. please help

Answer Source

Try -

var io = new require('')(http);

and make sure you are including this script on client side

<script src="/"></script>
var socket = io();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download