Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/georgestagg/webr-node-example
- Owner: georgestagg
- License: mit
- Created: 2023-03-22T08:34:35.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-03T13:45:24.000Z (over 1 year ago)
- Last Synced: 2023-11-03T14:39:05.248Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 2.93 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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
]
```