bun
bun copied to clipboard
Bun errors if main script is empty `Failed to run "test.js" due to error InvalidExe`
Version
0.1.6
Platform
Linux helipad 5.10.16.3-microsoft-standard-WSL2 (hashtag)1 SMP Fri Apr 2 22:23:49 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
What steps will reproduce the bug?
- Create a new a script and leave it empty
- Run the script
- Encounter the error
How often does it reproduce? Is there a required condition?
This error will always occur if the main script is empty.
What is the expected behavior?
Bun should not error if the main script is empty.
What do you see instead?
error: Failed to run "test.js" due to error InvalidExe
Additional information
If you import an empty file from another file, it does not error. This error only occurs if the main script is empty.
bun run hello.js
hello.js
import "./empty.tsx";
empty.tsx
- Running VSCodium (Visual Studio Code)
- Windows 10 Home using WSL
Could you upgrade to v0.1.8 and give it another try? This seems to be fixed. Close for now, feel free to reopen if the bug still exits :)
I have upgrade to v0.1.10 and it seems like this issue has reappeared 😆

~~I'm not sure if this is related or a separate issue. But I'm geetting a very similar error trying to run Purescript.~~
Operating System: Archlinux Bun version: 0.1.10 Steps to reproduce:
bun install purescriptbun run purs
Failed to run "purs" due to error InvalidExe
EDIT: Solved this. Purescript has a postinstall script, which didn't get run. I manually ran it, and now it works. :)
On bun v0.1.10, fresh installed on WSL/Ubuntu. Some commands don't seem to be executing correctly.
bun run package.jsonyieldserror: Failed to run "package.json" due to error InvalidExebun upgrade,bun installandbun c react .returns immediately without any messages in the console.bun devinside a react project directory states that it started a server, but closes immediately without any error message.
EDIT: found the other issue involving wsl/ubuntu and downgraded to 0.1.8
Reproducible example:
// index.ts
console.log(1)
bun build --compile index.ts --outfile asd # does not have .js
bun run asd # works
bun build index.ts --outfile asd # without compile
bun run asd
# error: Failed to run "asd" due to error InvalidExe
I have the same error executing bunx my-package and is just a file in bash (.sh). And with npx works fine...
We've since fixed this issue. As of Bun v1.0.7, this error no longer occurs. If you can still run into this problem after upgrading, please feel free to re-open this issue.
Been having this issue for about a week now, I've been trying ElysiaJS for a month, all has been great after I discovered that Bun alone will not run Prisma scripts, I needed Node to be installed too.
Anyway, bunx prisma db push gives me the error "Failed to run "prisma" due to error InvalidExe",
I'm on Bun 1.0.13, Prisma 5.6.0, Elysia 0.7.21, Windows 11 WSL2 on a Surface Laptop 2
We've since fixed this issue. As of Bun v1.0.7, this error no longer occurs. If you can still run into this problem after upgrading, please feel free to re-open this issue.
@Electroid I still have this bunx InvalidExe error in bun 1.0.21, to execute a simple bin with .sh extension...
the only commands in this bash: echo, read, mkdir, bun install. Can be problem of bun install inside this bash? Is it possible to try bunx locally without do releases to indentify where is the error on the bash? With npx works well... 😅
in the end, I solved it by changing the bin from .sh to .cjs with #!/usr/bin/env node shebang