javascript – Node.js找不到模块’tcp’

节点正在以下行崩溃:
var tcp = require('tcp'),

错误文字

node.js:201
    throw e; // process.nextTick error,or 'error' event on first tick
          ^
Error: Cannot find module 'tcp'
at Function._resolveFilename (module.js:334:11)
at Function._load (module.js:279:25)
at Module.require (module.js:357:17)
at require (module.js:368:17)
at Object.<anonymous> (C:\Program Files\nodejs\websocket\websocket.js:11:11)

at Module._compile (module.js:432:26)
at Object..js (module.js:450:10)
at Module.load (module.js:351:31)
at Function._load (module.js:310:12)
at Module.require (module.js:357:17)

问题是什么?我在互联网上找到了源码,作者和访问者也可以运行它

解决方法

请改用require(‘net’):
$node
> var tcp = require('tcp');
The 'tcp' module is Now called 'net'. Otherwise it should have a similar interface.
> var tcp = require('net');
> $

相关文章

前言 做过web项目开发的人对layer弹层组件肯定不陌生,作为l...
前言 前端表单校验是过滤无效数据、假数据、有毒数据的第一步...
前言 图片上传是web项目常见的需求,我基于之前的博客的代码...
前言 导出Excel文件这个功能,通常都是在后端实现返回前端一...
前言 众所周知,js是单线程的,从上往下,从左往右依次执行,...
前言 项目开发中,我们可能会碰到这样的需求:select标签,禁...