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

前端之家收集整理的这篇文章主要介绍了javascript – Node.js找不到模块’tcp’前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
节点正在以下行崩溃:
  1. var tcp = require('tcp'),

错误文字

  1. node.js:201
  2. throw e; // process.nextTick error,or 'error' event on first tick
  3. ^
  4. Error: Cannot find module 'tcp'
  5. at Function._resolveFilename (module.js:334:11)
  6. at Function._load (module.js:279:25)
  7. at Module.require (module.js:357:17)
  8. at require (module.js:368:17)
  9. at Object.<anonymous> (C:\Program Files\nodejs\websocket\websocket.js:11:11)
  10.  
  11. at Module._compile (module.js:432:26)
  12. at Object..js (module.js:450:10)
  13. at Module.load (module.js:351:31)
  14. at Function._load (module.js:310:12)
  15. at Module.require (module.js:357:17)

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

解决方法

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

猜你在找的JavaScript相关文章