* initial commit for Node.js binding * add c++ code * add inference session impl * e2e working * add settings.json * add test data * adjust binding declaration * refine tensor constructor declaration * update tests * enable onnx tests * simply refine readme * refine cpp impl * refine tests * formatting * add linting * move bin folder * fix linux build * manually update test filter list * update C++ API headers: fix crash in release build * make (manually) prebuild work * add test into prepack script * specify prebuild runtime type (N-API) * build.ts: update rebuild and include regex * fix lazy load on electron.js * update dev version, git link and binary host * support session options and run options * bump dev version * update README * add 1 example * move folder * adjust path * update document for examples * rename example 01 * add example 02 * add session option: log severity level * add example 04 * resolve comments * fix typo * remove double guard in header files * add copyright banner * move BUILD outside from README * consume test filter list from onnxruntime
1.1 KiB
Building Node.js binding
Pre-Requisites
- Node.js 12.x
Build Instructions
Currently it takes 4 steps to build Node.js binding:
-
Build ONNX Runtime with flag
--build_sharedin repo root. See Build for more info. -
In current folder, run
npm install. This will pull dev dependencies. -
Run
npm run buildto build binding. -
Run
npm testrun tests.
To consume the local built Node.js binding in a Node.js project:
npm install <onnxruntime-repo-root-folder>/nodejs
Publish
Publishing a NPM package with addon requires 2 steps: publish NPM package itself, and publish prebuild binaries.
Publish NPM package
To publish a release:
npm publish
To publish a @dev release:
npm publish --tag dev
To create a npm package (for local use or debug purpose):
npm pack
NOTE: Need to publish the package from a clean build, otherwise extra files may be packed.
Publish prebuild binaries
Currently, prebuild binaries only support 3 platforms on x64: win32/linux/macos.
Prebuilds are currently uploaded manually.