Node-redis: TypeError: net.isIP is not a function

Created on 28 May 2019  ·  7Comments  ·  Source: NodeRedis/node-redis

_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

Most helpful comment

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

All 7 comments

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

Which node version are you having this issue on?

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.

You're my hero. Thanks a lot!

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

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

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?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

twappworld picture twappworld  ·  7Comments

juriansluiman picture juriansluiman  ·  3Comments

Atala picture Atala  ·  3Comments

ghost picture ghost  ·  3Comments

yuany picture yuany  ·  4Comments