Deno compile with "--no-terminal" don't work
I'm trying to compile a very simple file named main.ts
The problem is that after compiling and running the executable, it's doesn't work, it's showing nothing,
but when i try to run the binary from a terminal it work.
PS> deno compile --no-terminal -A main.ts
Version:
v8 12.1.285.6
typescript 5.3.33 Replies
The
--no-terminal
flag for deno compile
is designed to prevent a terminal window from being opened when the compiled binary is run on Windows. This flag does not affect the functionality of your code; it only affects how the binary is executed in terms of terminal interaction.
If your compiled binary is not working as expected when not run from a terminal, it could be due to a variety of reasons unrelated to the --no-terminal
flag. Here are a few steps you can take to debug the issue:
1. Check Permissions: Ensure that the compiled binary has the necessary permissions to perform file operations. Since you are using the -A
flag, this should grant all permissions, but it's still worth verifying.
2. Check File Paths: When running the binary outside of a terminal, the current working directory might be different. Make sure that the path to 'test.txt' is accessible from wherever the binary is being executed.
3. Error Handling: Modify your main.ts
to include error handling to catch any exceptions that might occur during file writing. This can help identify if there's an issue with the file operation itself.
4. Logging: Add console logs before and after the file operation to see if the code is being executed at all when the binary is run outside of a terminal.
5. Check the Version: Make sure you are using a version of Deno that supports the --no-terminal
flag. According to the documentation, this feature was introduced in Deno 1.36. You can check your Deno version with deno --version
.
If after these steps the issue still persists, you may want to compilethe binary without the
--no-terminal
flag and run it from a terminal to see if any error messages are displayed. This can provide further insight into what might be going wrong.
Remember that when running the compiled binary outside of a terminal, you won't see console logs or errors unless you have a way to capture stdout and stderr. If the file 'test.txt' is not being created, it suggests that the binary is either not running at all, not running to completion, or encountering an error that prevents the file operation from succeeding.Can you open an issue? https://github.com/denoland/deno/issues