obsidian-execute-code icon indicating copy to clipboard operation
obsidian-execute-code copied to clipboard

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

Open luckman212 opened this issue 1 year ago • 3 comments

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

  • macOS 14.5
  • Obsidian 1.6.7
  • plugin ver 1.12.0
  • node version: v22.5.1
  • ts-node version: v10.9.2
~ $ /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 avatar Jul 29 '24 15:07 luckman212

JS runs ok, btw... same path

image image

luckman212 avatar Jul 29 '24 15:07 luckman212

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...

luckman212 avatar Jul 29 '24 15:07 luckman212

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:

  • https://github.com/nodejs/node/pull/53725

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

  • https://bun.sh/

zieka avatar Jul 29 '24 17:07 zieka