Skip to content

metacall/embedding-nodejs-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MetaCall Embedding NodeJS Example

This example shows how to embed NodeJS into C/C++ source code. The instructions are focused on Linux but it can be ported to other platforms easily.

Dependencies

For building this example you need NodeJS to be installed in the system (10.x has been tested) and Python 2.7 available as python command (due to NodeJS build system dependency). For debian based distros:

sudo apt-get install -y --no-install-recommends build-essential cmake ca-certificates git nodejs npm python2.7 node-gyp unzip
sudo npm install -g npm@latest
alias python=/usr/bin/python2.7

Build

Build the project, MetaCall dependency may require root permissions in order to be installed in the system.

git clone https://github.com/metacall/embedding-nodejs-example.git
mkdir embedding-nodejs-example/build && cd embedding-nodejs-example/build
cmake ..
cmake --build . --target install

Run

From project root directory, run the following commands:

export LOADER_LIBRARY_PATH="/usr/local/lib"
export LOADER_SCRIPT_PATH="`pwd`"
./embedding-nodejs-example

Docker

Building and running with Docker:

docker build --build-arg DISABLE_CACHE=`date +%s` -t metacall/embedding-nodejs-example .
docker run --rm -it metacall/embedding-nodejs-example