Skip to content

Commit 2afcbac

Browse files
committed
revert polyglot binary because windows
1 parent 49cbb34 commit 2afcbac

7 files changed

Lines changed: 15 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- Display `max_memory_restart` in `pm2 describe` output when set #5925
88
- Add missing `port` option to `StartOptions` TypeScript declaration #6045
99
- Fix incorrect file permissions on `openrc.tpl` template (0755 → 0644) #5957
10+
- Fix Windows cmd.exe regression: revert `bin/pm2*` launchers to `#!/usr/bin/env node` shebang (was polyglot `#!/bin/sh`). Polyglot worked on Linux/macOS but broke npm's `pm2.cmd` shim on Windows — `cmd.exe` can't interpret `/bin/sh` shebang and failed with `'"/bin/sh"' is not recognized as an internal or external command`. PowerShell's auto-generated `pm2.ps1` shim happened to call `node` directly so it kept working, masking the regression. Bun-only Linux/macOS users (no Node installed) need to symlink `node` to `bun` (`sudo ln -s $(which bun) /usr/local/bin/node`) — same workaround used in the project's bun test Dockerfile. Documented in README #6108
1011

1112
## 7.0.0
1213

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ $ npm install pm2 -g
5555
$ bun install pm2 -g
5656
```
5757

58+
If you only have Bun installed (no Node.js), symlink `node` to `bun` so PM2's `#!/usr/bin/env node` shebang resolves to Bun's node-compatibility runtime:
59+
60+
```bash
61+
$ sudo ln -s $(which bun) /usr/local/bin/node
62+
```
63+
5864
___
5965

6066
You can install Node.js easily with [NVM](https://github.com/nvm-sh/nvm#installing-and-updating) or [FNM](https://github.com/Schniz/fnm) or install Bun with `curl -fsSL https://bun.sh/install | bash`

bin/pm2

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#!/bin/sh
2-
':' //; exec "$(command -v node || command -v bun)" "$0" "$@"
1+
#!/usr/bin/env node
32

43
require('../lib/binaries/CLI.js');

bin/pm2-dev

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#!/bin/sh
2-
':' //; exec "$(command -v node || command -v bun)" "$0" "$@"
1+
#!/usr/bin/env node
32

43
require('../lib/binaries/DevCLI.js');

bin/pm2-docker

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#!/bin/sh
2-
':' //; exec "$(command -v node || command -v bun)" "$0" "$@"
1+
#!/usr/bin/env node
32

43
require('../lib/binaries/Runtime4Docker.js');

bin/pm2-runtime

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#!/bin/sh
2-
':' //; exec "$(command -v node || command -v bun)" "$0" "$@"
1+
#!/usr/bin/env node
32

43
require('../lib/binaries/Runtime4Docker.js');

test/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,13 @@ RUN if [ "$RUNTIME" = "node" ]; then \
3535
fi
3636

3737
# Install Bun when RUNTIME=bun
38+
# Symlink bun→node so #!/usr/bin/env node shebangs resolve to Bun's node-compat runtime.
39+
# Same workaround Bun-only users apply on host systems.
3840
RUN if [ "$RUNTIME" = "bun" ]; then \
3941
curl -fsSL https://bun.sh/install | bash && \
4042
ln -s /root/.bun/bin/bun /usr/local/bin/bun && \
41-
ln -s /root/.bun/bin/bunx /usr/local/bin/bunx; \
43+
ln -s /root/.bun/bin/bunx /usr/local/bin/bunx && \
44+
ln -s /root/.bun/bin/bun /usr/local/bin/node; \
4245
fi
4346

4447
# Install mocha globally (only needed for Node runtime)

0 commit comments

Comments
 (0)