找不到模块“socket.io/node_modules/redis" [英] Cannot find module 'socket.io/node_modules/redis'

查看:121
本文介绍了找不到模块“socket.io/node_modules/redis"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试时

var redis = require('socket.io/node_modules/redis');

我收到错误找不到模块‘socket.io/node_modules/redis",我不知道为什么.我正在运行 Windows 并运行npm install socket.io"

I get the error "Cannot find module 'socket.io/node_modules/redis" and I can't figure out why. I am running windows and ran "npm install socket.io"

这里似乎是同样的问题:错误:无法找到模块 'socket.io/node_modules/redis' 但 redis 服务器已启动并正在运行.

It seems like the same issue here: Error: Cannot find module 'socket.io/node_modules/redis' but the redis server is up and running.

在我的socket.io/node_modules"文件夹中,我没有看到任何与 Redis 相关的内容.

In my "socket.io/node_modules" folder I don't see anything Redis related.

推荐答案

socket.io package.json 不显示对 redis 的依赖:

The socket.io package.json doesn't show a dependency on redis:

  "dependencies": {
    "engine.io": "Automattic/engine.io#15afd3",
    "socket.io-parser": "2.2.1",
    "socket.io-client": "Automattic/socket.io-client#05c9632",
    "socket.io-adapter": "0.2.0",
    "has-binary-data": "0.1.3",
    "debug": "0.7.4"
  }

无论哪种方式,都不需要直接依赖另一个库的依赖项.如果您需要在代码中使用 redis,您可以安装 redis 并将其添加到您的 package.json 中:

Either way, theres no need to directly depend on another library's dependencies. If you need to use redis in your code, you can install redis and add it to your package.json using:

npm install redis --save

并要求:

var redis = require('redis');

这篇关于找不到模块“socket.io/node_modules/redis"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆