Open arkraieski opened 1 year ago
Hey,
This might have been fixed, the following code works:
index.ts
import express from "express";
import { WebR } from "webr";
const app = express();
const webR = new WebR();
await webR.init();
app.get("/", async (req, res) => {
let result = await webR.evalRString('tools::toTitleCase("hello from r!")') as String;
res.send(result);
});
app.listen(3000, () => {
console.log("http://localhost:3000/");
});
deno run --allow-net --allow-read --allow-env index.ts
curl http://localhost:3000
Hello from R!
deno --version
deno 1.44.4 (release, aarch64-apple-darwin)
v8 12.6.228.9
typescript 5.4.5
Hi, last night I was playing around with some scripts trying to get WebR to run in Deno, and unfortunately, it doesn't seem to work currently.
I'm not sure if anyone else is interested in this, but I figured it would be worthwhile to at least start the discussion (if it hasn't already been started) and discuss potential blockers. I'm interested in using Deno as novel way of deploying backend R and integrating with serverless web apps and apis, etc.
When I try importing webR from npm in Deno with the syntax
import {WebR} from "npm:@r-wasm/webr"
I got a nasty error trying to callnew WebR()
:I'm not really sure what all that means, but I got the same error even when running the script with the
-A
flag which grants all security permissions.Downloading WebR and importing from CDN as described in the WebR documentation results in a different error (seemingly from
src/webR/compat.ts
?) when I get to runningwebR.evalR()
:Is Deno compatibility/support something that's been discussed? Are there any known blockers that need to be addressed?
Thanks!