Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: net.isIP is not a function #1440

Open
RamanPndy opened this issue May 28, 2019 · 9 comments
Open

TypeError: net.isIP is not a function #1440

RamanPndy opened this issue May 28, 2019 · 9 comments

Comments

@RamanPndy
Copy link

Thanks for wanting to report an issue you've found in node_redis. Please delete
this text and fill in the template below. Please note that the issue tracker is only
for bug reports or feature requests. If you have a question, please ask that on [gitter].
If unsure about something, just do as best as you're able.

Note that it will be much easier to fix the issue if a test case that reproduces
the problem is provided. It is of course not always possible to reduce your code
to a small test case, but it's highly appreciated to have as much data as possible.
Thank you!

  • Version: What node_redis and what redis version is the issue happening on? 2.8.0
  • Platform: What platform / version? (For example Node.js 0.10 or Node.js 5.7.0 on Windows 7 / Ubuntu 15.10 / Azure) Windows
  • Description: Description of your issue, stack traces from errors and code that reproduces the issue

Hi Folks,
I'm trying to create Redis Client using this
var redis = require('redis');
var redisClient = redis.createClient({host:'127.0.0.1', port:6379});

but it throws me this errors
else {
82 | cnx_options.port = +options.port || 6379;
83 | cnx_options.host = options.host || '127.0.0.1';

84 | cnx_options.family = !options.family && net.isIP(cnx_options.host) || (options.family === 'IPv6' ? 6 : 4);
| ^ 85 | this.address = cnx_options.host + ':' + cnx_options.port;
86 | } // Warn on misusing deprecated functions
87 |

Please anyone suggest any workaround on this.

Thanks
[gitter]: https://gitter.im/NodeRedis/node_redis?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge

@baselbj
Copy link

baselbj commented Jul 16, 2019

I am facing the same issue when I changed line 3 in redis index.js file to var net = require('net-browserify');

for sure this is not a proper solution or work around but this fixes the issue for now until finding i find a solution

@Salakar
Copy link
Contributor

Salakar commented Feb 7, 2020

Which node version are you having this issue on?

@Salakar Salakar added this to the v3.0.0 milestone Feb 7, 2020
@shamim-42
Copy link

I am facing the same issue when I changed line 3 in redis index.js file to var net = require('net-browserify');

for sure this is not a proper solution or work around but this fixes the issue for now until finding i find a solution

Here it is also fixed by this way. Thanks.

@siyuano
Copy link

siyuano commented Jun 18, 2020

You're my hero. Thanks a lot!

@prophetchen
Copy link

how about this Issue? I am facing the same issue!!!!!

@prophetchen
Copy link

prophetchen commented Sep 8, 2020

npx create-react-app test_redis_react --typescript
cd test_redis_react

yarn add redis
info Direct dependencies
└─ [email protected]
info All dependencies
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
└─ [email protected]
✨ Done in 8.19s.

I fixed App.tsx like this

import React from 'react';
import logo from './logo.svg';
import './App.css';

function App() {
const redis = require('redis');
let client:any = redis.createClient(6379, "127.0.0.1", {db: 3});
client.get("key", redis.print);

return (
        <div className="App">
            <header className="App-header">
            <p>
            Edit <code>src/App.tsx</code> and save to reload.
            </p>
            </header>
        </div>
       );

}

export default App;

It's wrong!!!

Download the React DevTools for a better development experience: https://fb.me/react-devtools
index.js:67 Uncaught TypeError: net.isIP is not a function
at new RedisClient (index.js:67)
at Object.push../node_modules/redis/index.js.exports.createClient (index.js:1022)
at App (App.tsx:7)
at renderWithHooks (react-dom.development.js:14803)
at mountIndeterminateComponent (react-dom.development.js:17482)
at beginWork (react-dom.development.js:18596)
at HTMLUnknownElement.callCallback (react-dom.development.js:188)
at Object.invokeGuardedCallbackDev (react-dom.development.js:237)
at invokeGuardedCallback (react-dom.development.js:292)
at beginWork$1 (react-dom.development.js:23203)
at performUnitOfWork (react-dom.development.js:22157)
at workLoopSync (react-dom.development.js:22130)
at performSyncWorkOnRoot (react-dom.development.js:21756)
at scheduleUpdateOnFiber (react-dom.development.js:21188)
at updateContainer (react-dom.development.js:24373)
at react-dom.development.js:24758
at unbatchedUpdates (react-dom.development.js:21903)
at legacyRenderSubtreeIntoContainer (react-dom.development.js:24757)
at Object.render (react-dom.development.js:24840)
at Module../src/index.tsx (index.tsx:7)
at webpack_require (bootstrap:784)
at fn (bootstrap:150)
at Object.1 (serviceWorker.ts:149)
at webpack_require (bootstrap:784)
at checkDeferredModules (bootstrap:45)
at Array.webpackJsonpCallback [as push] (bootstrap:32)
at main.chunk.js:1

node --version
v12.18.3

npm --version
6.14.6

@prophetchen
Copy link

I printed net in App.tsx,
result like this:

net:
Object
proto:
constructor: ƒ Object()
hasOwnProperty: ƒ hasOwnProperty()
isPrototypeOf: ƒ isPrototypeOf()
propertyIsEnumerable: ƒ propertyIsEnumerable()
toLocaleString: ƒ toLocaleString()
toString: ƒ toString()
valueOf: ƒ valueOf()
defineGetter: ƒ defineGetter()
defineSetter: ƒ defineSetter()
lookupGetter: ƒ lookupGetter()
lookupSetter: ƒ lookupSetter()
get proto: ƒ proto()
set proto: ƒ proto()

The net module is the base Module of node.js, BUT it's miss in this tsx file!!!
WHY? And How Can I do?

@prrenish
Copy link

I am facing the same issue when I changed line 3 in redis index.js file to var net = require('net-browserify');

for sure this is not a proper solution or work around but this fixes the issue for now until finding i find a solution

Tried but still same issue and also need to add "net" and "tls" to the package.json file since its not present in the library.

Thanks in advance

@leibale leibale removed this from the v3.0.0 milestone Jun 29, 2021
@StudentWvl
Copy link

I had the same problem and found that in the console:
Uncaught TypeError: net.createConnection is not a function
this error caused by line 197 in redis index.js
this.stream = net.createConnection(this.connection_options);
Anyone can help me please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants