Error: Cannot find module 'socket.io'

前端 未结 6 750
闹比i
闹比i 2020-12-16 10:02
[~]# node node.js

Error: Cannot find module \'socket.io\'

[~]# node -v
v0.10.10

socket.io installed:

npm install socket.io

npm W         


        
6条回答
  •  心在旅途
    2020-12-16 10:46

    This almost happens than you try to get socket.io in you html files like :

    index.html

    where you have:

     < script type="text/javascript" src="/socket.io/socket.io.js">
    

    It will not find socket.io because you did not started module in you application file wich contain the server like

    server.js

    You must include following lines after started your server in server.js :

    var io = require('socket.io').listen(server);
    

    Hope, will save time.

提交回复
热议问题