Socks
Socks4mo ago

Deno compile not able to create files?

I want to create a simple CLI for a colleague at work that outputs a CSV file but I cannot seem to get Deno to create a file, even with the simplest of tests. When I run this normally using Deno run -A index.ts it will work as intended but when compiled and run through the executable it will run successfully but no file is created. Target OS: Windows Dev OS: Mac M1 (arm) CODE
async function main() {
await Deno.writeTextFile("hello.txt", "Hello World\n");
}
main()
async function main() {
await Deno.writeTextFile("hello.txt", "Hello World\n");
}
main()
Compile Command
Deno compile -A index.ts
Deno compile -A index.ts
6 Replies
marvinh.
marvinh.4mo ago
Works fine for me. The text file is created in the folder where you ran the command. Maybe you looked somewhere else for it?
Socks
Socks4mo ago
I am in the same folder as the compiled executable.. Are you also testing on Mac m1?
marvinh.
marvinh.4mo ago
yeah, have the M2 here, but that shouldn't make any difference
Leokuma
Leokuma4mo ago
I believe cross-compiled Deno apps have problems with relative paths Try something like Deno.cwd() + '/hello.txt'
Socks
Socks4mo ago
@Lek You might be right. I will give that try for my mac testing. I compiled to windows and copied that version over to my windows machine and it worked correctly. It must be something specific with the default cross compiled target on mac arm. @marvinh. - Are you specifying a specific target with your compile for mac?
marvinh.
marvinh.4mo ago
No, running the exact same commands as you listed here