Skip to content

Commit 97acb26

Browse files
committed
docs: add docs
1 parent 23fd878 commit 97acb26

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,23 @@ await exec(['app.js', '--target', 'host', '--output', 'app.exe']);
402402

403403
## Troubleshooting
404404

405+
### Error: Cannot find module XXX (when using `child_process`)
406+
407+
When using `child_process` methods to run a new process pkg by default will invoke it using NodeJS runtime that is built into the executable. This means that if you are trying to spawn the packaged app itself you will get above error. In order to avoid this you must set `PKG_EXECPATH` env set to `""`:
408+
409+
```js
410+
const { spawn } = require('child_process');
411+
412+
const child = spawn(process.execPath, [process.argv[1]], {
413+
env: {
414+
...process.env,
415+
PKG_EXECPATH: '',
416+
},
417+
});
418+
```
419+
420+
More info [here](https://github.com/yao-pkg/pkg/pull/90)
421+
405422
### Error: ENOENT: no such file or directory, uv_chdir
406423

407424
This error can be caused by deleting the directory the application is

prelude/bootstrap.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2006,6 +2006,7 @@ function payloadFileSync(pointer) {
20062006
}
20072007
const opts = args[pos];
20082008
if (!opts.env) opts.env = _extend({}, process.env);
2009+
// see https://github.com/vercel/pkg/issues/897#issuecomment-1049370335
20092010
if (opts.env.PKG_EXECPATH !== undefined) return;
20102011
opts.env.PKG_EXECPATH = EXECPATH;
20112012
}

0 commit comments

Comments
 (0)