Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

[BUG] can't run child_process.fork with string code #2039

Closed
damartripamungkas opened this issue Dec 24, 2023 · 1 comment
Closed

[BUG] can't run child_process.fork with string code #2039

damartripamungkas opened this issue Dec 24, 2023 · 1 comment

Comments

@damartripamungkas
Copy link

What version of pkg are you using?

5.8.1

What version of Node.js are you using?

20.3.1

What operating system are you using?

macOs, Windows, Linux

What CPU architecture are you using?

x64

What Node versions, OSs and CPU architectures are you building for?

node18

Describe the Bug

can't run child_process.fork with string code and parameter { execArgv: ["--eval"] }
full code :

const { fork } = require("node:child_process");

const codeStr = `
    setInterval(() => {
        console.log('sub process:' + Math.random())
    }, 1000)
`;

fork(codeStr, { execArgv: ["--eval"] });

error :

node:internal/modules/cjs/loader:949
  throw err;
  ^

Error: Cannot find module 'C:\custom-main\--eval'
←[90m    at Module._resolveFilename (node:internal/modules/cjs/loader:946:15)←[39m
    at Function._resolveFilename (pkg/prelude/bootstrap.js:1951:46)
←[90m    at Module._load (node:internal/modules/cjs/loader:787:27)←[39m
    at Function.runMain (pkg/prelude/bootstrap.js:1979:12)
←[90m    at node:internal/main/run_main_module:17:47←[39m {
  code: ←[32m'MODULE_NOT_FOUND'←[39m,
  requireStack: []
}

Node.js v18.5.0

Expected Behavior

running

To Reproduce

above

@damartripamungkas
Copy link
Author

solved because I changed the method to worker_thread, not because of anything else

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

No branches or pull requests

1 participant