NodeJS: socksv5: How to fix error normalizeConnectArgs is not a function


Example error:

[root@tutorialspots drive4]# node test.js
/home/drive4/node_modules/socksv5/lib/client.js:225
  var args = normalizeConnectArgs(arguments),
             ^

TypeError: normalizeConnectArgs is not a function
    at Agent.exports.connect.exports.createConnection (/home/drive4/node_modules/socksv5/lib/client.js:225:14)
    at Agent.createSocket (/home/drive4/node_modules/socksv5/lib/Agents.js:225:21)
    at Agent.addRequest (/home/drive4/node_modules/socksv5/lib/Agents.js:194:23)
    at new ClientRequest (_http_client.js:258:16)
    at request (http.js:42:10)
    at Object.get (http.js:46:13)
    at Object.<anonymous> (/home/drive4/test.js:10:6)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)

How to fix this error?

Step 1: remove package socksv5

[root@tutorialspots drive4]# npm rm socksv5
npm WARN drive-m3u8-team@1.0.0 No description
npm WARN drive-m3u8-team@1.0.0 No repository field.

removed 21 packages and audited 141 packages in 0.946s
found 0 vulnerabilities

Step 2: install package @luminati-io/socksv5

[root@CentOS-82-64-minimal drive4]# npm i @luminati-io/socksv5
npm WARN drive-m3u8-team@1.0.0 No description
npm WARN drive-m3u8-team@1.0.0 No repository field.

+ @luminati-io/socksv5@0.0.7
added 21 packages from 16 contributors and audited 162 packages in 3.414s

1 package is looking for funding
  run `npm fund` for details

found 1 low severity vulnerability
  run `npm audit fix` to fix them, or `npm audit` for details

Step 3: change code

const socks = require('socksv5')

to:

const socks = require('@luminati-io/socksv5')

Step 4: restart pm2 or forever

pm2 restart index

Leave a Reply