本文介绍了节点js错误:找不到模块'./lib/socket.io'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我让我的服务器使用了早期版本的node.js,npm和socket.io但是在更新后我开始遇到socket.io的问题:

I had my server working with an earlier version of node.js, npm, and socket.io but after updating I started getting issues with socket.io:

    Error: Cannot find module './lib/socket.io'
    at Function._resolveFilename (module.js:333:15)
    at Function._load (module.js:280:25)
    at Module.require (module.js:357:17)
    at require (module.js:373:17)
    at Object.<anonymous> (/usr/local/lib/node_modules/socket.io/index.js:8:18)
    at Module._compile (module.js:444:26)
    at Object..js (module.js:462:10)
    at Module.load (module.js:351:32)
    at Function._load (module.js:309:12)
    at Module.require (module.js:357:17)

我已经用命令npm

i have installed socket.io module with command npm

install socket.io

将socket.io放在我项目中的node_modules下。我一开始觉得奇怪的是错误信息是./lib/socket.io,但是当我查看它时,我发现project / node_modules / socket.io / index.js需要socket.io,如下所示:

which placed socket.io under node_modules in my project. I found it strange at first that the error message was saying "./lib/socket.io" but when I looked into it I found that project/node_modules/socket.io/index.js is requiring socket.io like so:

module.exports = require('./lib/socket.io');

此行给出错误错误:找不到模块'./lib/socket.io'

this line giving me error Error: Cannot find module './lib/socket.io'

请帮帮我

提前致谢

推荐答案

尝试 npm cache clean 我遇到了类似的问题,我在这里找到了这个提示:

Try npm cache clean I had a similar problem, and I found this tip here: http://codebetter.com/glennblock/2012/02/27/my-tale-of-npm-woe-when-all-else-fails-clear-you-cache/

这篇关于节点js错误:找不到模块'./lib/socket.io'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 04:56