onnxruntime/js/node
Yulong Wang 780735098d
[nodejs binding] Fix building in latest clang (#23146)
### Description

This change fixes the build break for Node.js binding on latest
AppleClang:

```
...tensor_helper.cc:65:5 error: integer value -1 is outside of the valid range of values [0,15] for the enumeration type 'napi_typedarray_type' [-Wenum-constexpr-conversion]

```

Use the underlying type of enum `napi_typedarray_type` for
`DATA_TYPE_TYPEDARRAY_MAP` to solve this issue.

Because the underlying type is implementation defined (it's `int` for
MSVC and `unsigned int` for Clang), we use `std::underlying_type_t` to
get the correct type.
2024-12-19 10:23:27 -08:00
..
lib support WebGPU EP in Node.js binding (#22660) 2024-11-04 21:09:07 +00:00
script [js/node] fix CUDA artifact installation script for Linux/x64 (#22984) 2024-12-03 16:07:43 -08:00
src [nodejs binding] Fix building in latest clang (#23146) 2024-12-19 10:23:27 -08:00
test [js] change default formatter for JavaScript/TypeScript from clang-format to Prettier (#21728) 2024-08-14 16:51:22 -07:00
.gitignore [Node.js binding] Allow installation to download CUDA binaries via script (#20364) 2024-04-18 13:44:42 -07:00
.npmignore [Node.js binding] Allow installation to download CUDA binaries via script (#20364) 2024-04-18 13:44:42 -07:00
CMakeLists.txt support WebGPU EP in Node.js binding (#22660) 2024-11-04 21:09:07 +00:00
package-lock.json Bump axios from 1.6.1 to 1.7.9 in /js/node (#23009) 2024-12-04 23:52:24 +00:00
package.json bumps up version in main from 1.20 -> 1.21 (#22482) 2024-10-17 12:32:35 -07:00
README.md Update Node.js version from 18.x to 20.x in CI pipelines (#22576) 2024-10-24 07:34:42 -07:00
tsconfig.json [js/node] fix TypeScript declaration in onnxruntime-node (#23000) 2024-12-04 11:29:27 -08:00

ONNX Runtime Node.js Binding

ONNX Runtime Node.js binding enables Node.js applications to run ONNX model inference.

Usage

Install the latest stable version:

npm install onnxruntime-node

Refer to ONNX Runtime JavaScript examples for samples and tutorials.

Requirements

ONNXRuntime works on Node.js v16.x+ (recommend v20.x+) or Electron v15.x+ (recommend v28.x+).

The following table lists the supported versions of ONNX Runtime Node.js binding provided with pre-built binaries.

EPs/Platforms Windows x64 Windows arm64 Linux x64 Linux arm64 MacOS x64 MacOS arm64
CPU ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
DirectML ✔️ ✔️
CUDA ✔️[1]
  • [1]: CUDA v11.8.

To use on platforms without pre-built binaries, you can build Node.js binding from source and consume it by npm install <onnxruntime_repo_root>/js/node/. See also instructions for building ONNX Runtime Node.js binding locally.

GPU Support

Right now, the Windows version supports only the DML provider. Linux x64 can use CUDA and TensorRT.

CUDA EP Installation

To use CUDA EP, you need to install the CUDA EP binaries. By default, the CUDA EP binaries are installed automatically when you install the package. If you want to skip the installation, you can pass the --onnxruntime-node-install-cuda=skip flag to the installation command.

npm install onnxruntime-node --onnxruntime-node-install-cuda=skip

You can also use this flag to specify the version of the CUDA: (v11 or v12)

npm install onnxruntime-node --onnxruntime-node-install-cuda=v12

License

License information can be found here.