I just made an example of TypeScript interop via NodeJS - can anyone with npm
installed try this out and let me know if it works for you? https://github.com/roc-lang/roc/pull/5146
Worked for me. I had issues with npm install
and node-gyp , ended up just installing each package manually and it worked fine for some reason, same versions even..
Calling Roc...
Called Roc...
Roc says the following: TypeScript said to Roc: Hello from TypeScript! :tada:
hm, that's weird - I'm not sure what to make of that :sweat_smile:
what OS was this on?
Mac OS - Ventura 13.0
huh! I'm also on macOS :thinking:
what versions of node and npm?
Lets see..
node: v18.12.1
npm: 8.19.3
I can't seem to recreate it now. I did restart my computer somewhere in debugging the issue, we can just blame it on local env issues .. :sweat_smile:
Seth Workman said:
I had issues with
npm install
and node-gyp , ended up just installing each package manually and it worked fine for some reason
needed npm install --ignore-scripts
to avoid problems
LIBHELLO_FILENAME=$(or $(wildcard libhello.*), libhello)
run-ts: $(LIBHELLO_FILENAME) hello.ts
npx ts-node hello.ts
run-js: hello.js
node hello.js
hello.js: $(LIBHELLO_FILENAME) hello.ts
npx tsc hello.ts
$(LIBHELLO_FILENAME): build demo.c *.roc
roc build --lib
npx node-gyp build
cp addon.d.ts build/Release/
build: node_modules
npx node-gyp configure
# ignore-scripts is needed otherwise error:
# ld: library not found for -lhello
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
node_modules:
npm install --ignore-scripts
clean:
rm -rf libhello.dylib build hello.js node_modules
Last updated: Jul 05 2025 at 12:14 UTC