stencila-nodedeprecated

Stencila for Node.js

Usage no npm install needed!

<script type="module">
  import stencilaNode from 'https://cdn.skypack.dev/stencila-node';
</script>

README

Stencila for Node.js

NPM Build status Build status Code coverage Dependency status Chat

Install

npm install stencila-node --global --python=python2.7

This package relies on dependencies with native add-ons (e.g. better-sqlite3, xeromq). So you will need to have node-gyp installed (https://github.com/nodejs/node-gyp#readme). The --python flag is necessary because, on OSX and Windows, node-gyp is only compatible with Python 2.7.

Register this Stencila package,

stencila-node register

This creates a host manifest file in the Stencila hosts directory (e.g. ~/.stencila/hosts/node.js on Linux). This file is used by Stencila Desktop and other packages to determine which Stencila hosts you have installed on your machine.

Use

This package lets you run JavaScript and other code from inside Stencila documents. First, you need to start serving the Stencila Host within this package. You can do that at a terminal,

stencila-node

or inside Node.js:

const stencila = require('stencila-node')
stencila.run()

This will serve a Stencila Host on localhost. You can then open your Stencila document from within the Stencila Desktop. The host will be automatically detected by the desktop app and you'll be able to execute Javascript code cells from within your documents.

You can also use this package to compile libraries of Javascript functions for use within Stencila:

stencila-node compile "~/stencila/source/libcore/"

This creates a minified Javascript bundle, in this example at "~/stencila/source/libcore/libcore.min.js

API documentation is available at https://stencila.github.io/node.

Discuss

We love feedback. Create a new issue, add to existing issues or chat with members of the community.

Contribute

See CONTRIBUTING.md.