zoukankan      html  css  js  c++  java
  • Cannot find module 'socket.io'

    
    
    That's all. Then I try to use socket.io with this line:
    
    var io = require('socket.io').listen(app);
    And it output an error:
    
    Error: Cannot find module 'socket.io'
        at Function.Module._resolveFilename (module.js:338:15)
        at Function.Module._load (module.js:280:25)
        at Module.require (module.js:364:17)
        at require (module.js:380:17)
        at Object.<anonymous> (F:
    odejschat.js:8:10)
        at Module._compile (module.js:456:26)
        at Object.Module._extensions..js (module.js:474:10)
        at Module.load (module.js:356:32)
        at Function.Module._load (module.js:312:12)
        at Function.Module.runMain (module.js:497:10)

    I've tried all suggested method like cleaning cache, reinstalling nodejs or changing socket.io module path. Unfortunately, all of those solutions didn't solve this problem.

    This terrible error killed my whole day. I greatly appreciate any help.

    解决方法:

    Try to execute npm install socket.io in the folder where your node.js file is (where you require the module). npm creates a folder node_modules wherever you execute npm install socket.io and you probably didn't do this in the correct folder.

    npm install supervisor -g did work because -g is the global flag and you can basically do that anywhere.

  • 相关阅读:
    mssql 2008 数据库可疑
    sss
    css 浏览器兼容 重置代码
    .net 接口与 foreach必要条件
    .net获取ip
    flash与js的通信
    WebService传输文件的几个知识点
    【前端】深入浅出Javascript中的数值转换
    [前端]代理知识入门介绍
    Hello 博客园! ---致我人生中的第一篇随笔
  • 原文地址:https://www.cnblogs.com/smiler/p/4628294.html
Copyright © 2011-2022 走看看