Skip to content

Latest commit

 

History

History
41 lines (29 loc) · 1.24 KB

install-nodejs.md

File metadata and controls

41 lines (29 loc) · 1.24 KB

Install Node.js interface

DeePMD-kit has an inference interface for Node.js, the most common programming language in the world, via a wrapper of the header-only C++ interface created by SWIG.

Install from npm

npm i deepmd-kit
# Or if you want to install globally
npm i -g deepmd-kit

Build from source

Before building DeePMD-kit, install Node.js, SWIG (v4.1.0 for Node.js v12-v18 support), and node-gyp globally.

When using CMake to build DeePMD-kit from source, set argument BUILD_NODEJS_IF=ON and NODEJS_INCLUDE_DIRS=/path/to/nodejs/include (the path to the include directory of Node.js):

cmake -D BUILD_NODEJS_IF=ON \
      -D NODEJS_INCLUDE_DIRS=/path/to/nodejs/include \
      .. # and other arguments
make
make install

After installing DeePMD-kit, two files, bind.gyp and deepmdJAVASCRIPT_wrap.cxx will be generated in $deepmd_source_dir/source/nodejs.

Go to this directory, and install the Node.js package globally:

cd $deepmd_source_dir/source/nodejs
npm i
npm link

The deepmd-kit package should be globally available in Node.js environments:

const deepmd = require("deepmd-kit");