Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node.js Cannot find module 'tcp'

node is crashing at the following line:

var tcp = require('tcp'),

error text:

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)

What is the problem? I found the source on the Internet, and the author, and the visitors also can run it...

like image 571
Uw001 Avatar asked Nov 20 '11 00:11

Uw001


People also ask

Can not find module in node JS?

If you are getting the "Cannot find module" error when trying to run a local file, make sure that the path you passed to the node command points to a file that exists. For example, if you run node src/index. js , make sure that the path src/index. js points to an existing file.

Can not find module node path?

To solve the "Cannot find module path or its corresponding type declarations" error, install the types for node by running the command npm i -D @types/node . You can then import path with the following line of code import * as path from 'path' .

Can not find module npm?

To fix the Cannot find module error, simply install the missing modules using npm . This will install the project's dependencies into your project so that you can use them. Sometimes, this might still not resolve it for you. In this case, you'll want to just delete your node_modules folder and lock file ( package-lock.

Can not find module Express error?

To solve the error "Cannot find module 'express'", install the package by running the command npm install express in the root directory of your project. If you don't have a package. json file, create one by running npm init -y . The error occurs when we try to import the express package without installing it.


1 Answers

Try require('net') instead:

$ node
> var tcp = require('tcp');
The 'tcp' module is now called 'net'. Otherwise it should have a similar interface.
> var tcp = require('net');
> $ 
like image 91
sarnold Avatar answered Oct 23 '22 13:10

sarnold