Node.js + socket.io找不到模块 [英] Nodejs+socket.io cannot find module
问题描述
我尝试按照本教程进行操作( http://www.radiusdesk.com/getting_started/install_ubuntu_node.js )而且我坚持使用nodejs步骤.
i try to follow this tutorial (http://www.radiusdesk.com/getting_started/install_ubuntu_node.js) and i stuck on the nodejs step.
我安装了nodejs,但是socket.io模块出现了问题.
I installed nodejs but theres a problem with the socket.io module.
日志-> http://pastebin.com/DK2XSSeM
我使用sudo npm -g install socket.io@0.9.x进行安装../usr/local/lib/node_modules/socket.io存在.
I used sudo npm -g install socket.io@0.9.x to install../usr/local/lib/node_modules/socket.io exists..
操作系统:Raspian(raspberrypi)
OS: Raspian (raspberrypi)
谢谢:)
推荐答案
Socket.io不是全局节点模块.您需要将其安装在项目本地,然后require()在代码中使用它.
Socket.io is not a global node module. You need to install it locally in the project and require() it use it in the code.
npm i --S socket.io
然后
let socket = require('socket'); // something like that
这篇关于Node.js + socket.io找不到模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!