twibiral / obsidian-execute-code

Obsidian Plugin to execute code in a note.
MIT License
1.06k stars 67 forks source link

[BUG] Can't execute ts codeblocks - macOS - node installed via https://github.com/tj/n #369

Open luckman212 opened 1 month ago

luckman212 commented 1 month ago

Describe the bug

ts codeblocks fail to execute, with a env: node: No such file or directory error. I have checked my paths and settings.

Software Version

~ $ /Users/luke/.n/bin/ts-node --version
v10.9.2
~ $ /Users/luke/.n/bin/node --version
v22.5.1

To Reproduce

image

Screenshots

image

image
luckman212 commented 1 month ago

JS runs ok, btw... same path

image image
luckman212 commented 1 month ago

Seems heavily related... https://github.com/twibiral/obsidian-execute-code/issues/87

edit: after reading through all the way to the end of that issue, the simplest fix was to switch to bun (thanks @zieka!)

I installed it to /usr/local/bin btw:

$ which bun
/usr/local/bin/bun

et voilà ...

image

@twibiral I might suggest making this a default as it seems "out of the box" that ts-node is just broken on macOS...

zieka commented 1 month ago

edit: after reading through all the way to the end of that issue, the simplest fix was to switch to bun (thanks @zieka!)

no problem 🍻

Also looks like node might support directly running ts files in the near future via an experimental flag:

For now though using an executable that already can like bun seems to be the easiest: