Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,23 @@ await exec(['app.js', '--target', 'host', '--output', 'app.exe']);

## Troubleshooting

### Error: Cannot find module XXX (when using `child_process`)

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 `""`:

```js
const { spawn } = require('child_process');

const child = spawn(process.execPath, [process.argv[1]], {
env: {
...process.env,
PKG_EXECPATH: '',
},
});
```

More info [here](https://github.com/yao-pkg/pkg/pull/90)

### Error: ENOENT: no such file or directory, uv_chdir

This error can be caused by deleting the directory the application is
Expand Down
3 changes: 2 additions & 1 deletion prelude/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -2006,7 +2006,8 @@ function payloadFileSync(pointer) {
}
const opts = args[pos];
if (!opts.env) opts.env = _extend({}, process.env);
if (opts.env.PKG_EXECPATH === 'PKG_INVOKE_NODEJS') return;
// see https://github.com/vercel/pkg/issues/897#issuecomment-1049370335
if (opts.env.PKG_EXECPATH !== undefined) return;
opts.env.PKG_EXECPATH = EXECPATH;
}

Expand Down