0

ok so here is my code im not sure what the problem is because if i manually type node start.js username:[email protected]:22225 it works fine. Thanks in advance

const cp = require('child_process') const path = require('path') const proxies =['username:[email protected]:22225','username:[email protected]:22225','username:[email protected]:22225'] var sleep = require('sleep') var maxproxies = 30 for (let i = 0; i < proxies.length; i++) { var child = cp.fork("./index.js", proxies[i]) console.log('Proxy '+ i+1 + ' loaded') sleep.sleep(5) } but when i load it errors with this TypeError [ERR_INVALID_ARG_VALUE]: The argument 'arguments[1]' is invalid. Received 'username:[email protected]:22225' ?[90m at Object.fork (child_process.js:73:13)?[39m at Object.<anonymous> (C:\Users\smkam\Desktop\test\start.js:7:20) ?[90m at Module._compile (internal/modules/cjs/loader.js:956:30)?[39m ?[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)?[39m ?[90m at Module.load (internal/modules/cjs/loader.js:812:32)?[39m ?[90m at Function.Module._load (internal/modules/cjs/loader.js:724:14)?[39m ?[90m at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10)?[39m ?[90m at internal/main/run_main_module.js:17:11?[39m { code: ?[32m'ERR_INVALID_ARG_VALUE'?[39m ? 

2 Answers 2

2

The second param of child_process.fork is an array, but you provided a string.

Sign up to request clarification or add additional context in comments.

8 Comments

but proxies[i] is an array?
so shouldnt var proxyParsed = JSON.parse(proxies[i]) work then
proxies is an array, proxies[i] is one of 'username:[email protected]:22225','username:[email protected]:22225','username:[email protected]:22225', it's a string.
You can try this: ``` var child = cp.fork("./index.js", [proxies[i]]); ```
it responsed the same as my code var proxyParsed = JSON.prase(proxies[i]) error code undefined:1 SyntaxError: Unexpected token l in JSON at position 0 the 1 is referring to my proxy url
|
0

I solved it i simply created an empty array push the proxies from the array once every loop

for (let i = 0; i < proxies.length; i++) { var proxy = [] proxy.push(proxies[i]) var child = cp.fork("./index.js", proxy); console.log('Proxy ' + i + 1 + ' loaded') sleep.sleep(5) } 

1 Comment

var child = cp.fork("./index.js", [proxies[i]]); is a better choice.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.