Commit aa5533b
committed
fix(dev-scripts): absolutize NODE_OPTIONS --require for portless cwd
`pnpm console:dev` / `pnpm ee-api:dev` (and `pnpm ui:dev`) crash on
startup with `Cannot find module 'env-preload'`.
Root cause: the root .npmrc sets `node-options=--require=env-preload`
so every pnpm-spawned node process inherits
`NODE_OPTIONS=--require=env-preload`. run-app.ts spawns portless with
`cwd: SHIM_DIR` (a non-git scratch dir, deliberately outside any
`node_modules`) to dodge portless's hardcoded worktree subdomain
prefix. portless is itself a node binary; it tries to load
`env-preload` from `SHIM_DIR` and dies in `loadPreloadModules`
before the inner bash ever runs.
Fix: rewrite `--require=NAME` (and `-r NAME`) tokens in NODE_OPTIONS
to absolute paths via `createRequire(import.meta.url).resolve()` before
spawning portless. With absolute paths, the cwd switch is harmless;
both portless and the inner `next dev` get the preload.
Portless has no flag, env var, or config field to disable the worktree
prefix on its `run` / `<name> <cmd>` paths (only `portless get` honors
`--no-worktree`), so SHIM_DIR has to stay.1 parent 3e6292b commit aa5533b
1 file changed
Lines changed: 49 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| 26 | + | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
| |||
78 | 80 | | |
79 | 81 | | |
80 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
81 | 123 | | |
82 | 124 | | |
83 | 125 | | |
| |||
118 | 160 | | |
119 | 161 | | |
120 | 162 | | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
121 | 169 | | |
122 | 170 | | |
123 | 171 | | |
| 172 | + | |
124 | 173 | | |
125 | 174 | | |
126 | 175 | | |
| |||
0 commit comments