Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/georgestagg/webr-node-example

An example of running webR under node.
https://github.com/georgestagg/webr-node-example

Last synced: 3 months ago
JSON representation

An example of running webR under node.

Awesome Lists containing this project

README

        

# Example of running webR under node

This repo contains an example of importing and running webR under node. The `webr` npm package contains both CommonJS and ES Module versions of the webR JavaScript loader, and so the following two examples are included,

* `index.js` loads the CommonJS build of webR using the `require()` function.
* `index.mjs` loads ES Module build of webR using `import` statement.

## Running the example (Linux/macOS)

* Clone this repo and `cd` into the new directory.
* Install webR: `npm install`, or `npm install webr`.
* Run the examples: `node index.js`, `node index.mjs`, or `npx tsx index.mts`.

If successful, the example will load webR and display 10 normally distributed random numbers,

```
$ node index.mjs
Result of running `rnorm` from webR: [
5.353056062381611,
5.250212064338357,
6.701975264508905,
4.524907550257074,
5.1218367202394255,
3.6861353558585437,
4.619462419163489,
4.900875077530067,
1.31186251698673,
5.399812408313427
]
```