deno
e0072edd - fix(install): inject -A and node-compat flags for npm:node-gyp shims

Commit
159 days ago
fix(install): inject -A and node-compat flags for npm:node-gyp shims `deno install -g npm:node-gyp` generates a shell shim of the form `exec deno run <args> npm:node-gyp "$@"`, where `<args>` only contains the permission flags the user typed at install time. With no flags, the shim runs `npm:node-gyp` with zero permissions, and node-gyp's transitive `env-paths` dies on its very first `os.homedir()` call with `NotCapable: Requires sys access to "homedir"` before printing anything. The same applies to the Node compat unstable flags that `NodeCommand` in `cli/task_runner.rs` already passes when running `node` scripts inside lifecycle scripts (bare-node-builtins, detect-cjs, sloppy-imports, unsafe-proto). node-gyp is essentially node code and needs them too. Special-case `npm:node-gyp` in the shim generator: detect via `NpmPackageReqReference` and force `-A` plus the four unstable flags, overriding any user-supplied permission flags (narrower permissions would just produce a shim that fails on first run anyway).
Author
Parents
Loading