docs(nodejs-addon-examples): add guide for pnpm user (#1401)
This commit is contained in:
@@ -12,19 +12,31 @@ Note: [../nodejs-examples](../nodejs-examples) uses WebAssembly to wrap
|
|||||||
Before you continue, please first run
|
Before you continue, please first run
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install
|
npm install # or pnpm install
|
||||||
|
|
||||||
# For macOS x64
|
# For macOS x64
|
||||||
|
## With npm
|
||||||
export DYLD_LIBRARY_PATH=$PWD/node_modules/sherpa-onnx-darwin-x64:$DYLD_LIBRARY_PATH
|
export DYLD_LIBRARY_PATH=$PWD/node_modules/sherpa-onnx-darwin-x64:$DYLD_LIBRARY_PATH
|
||||||
|
## With pnpm
|
||||||
|
export DYLD_LIBRARY_PATH=$PWD/node_modules/.pnpm/sherpa-onnx-node@<REPLACE-THIS-WITH-THE-INSTALLED-VERSION>/node_modules/sherpa-onnx-darwin-x64:$DYLD_LIBRARY_PATH
|
||||||
|
|
||||||
# For macOS arm64
|
# For macOS arm64
|
||||||
|
## With npm
|
||||||
export DYLD_LIBRARY_PATH=$PWD/node_modules/sherpa-onnx-darwin-arm64:$DYLD_LIBRARY_PATH
|
export DYLD_LIBRARY_PATH=$PWD/node_modules/sherpa-onnx-darwin-arm64:$DYLD_LIBRARY_PATH
|
||||||
|
## With pnpm
|
||||||
|
export DYLD_LIBRARY_PATH=$PWD/node_modules/.pnpm/sherpa-onnx-node@<REPLACE-THIS-WITH-THE-INSTALLED-VERSION>/node_modules/sherpa-onnx-darwin-arm64:$DYLD_LIBRARY_PATH
|
||||||
|
|
||||||
# For Linux x64
|
# For Linux x64
|
||||||
|
## With npm
|
||||||
export LD_LIBRARY_PATH=$PWD/node_modules/sherpa-onnx-linux-x64:$LD_LIBRARY_PATH
|
export LD_LIBRARY_PATH=$PWD/node_modules/sherpa-onnx-linux-x64:$LD_LIBRARY_PATH
|
||||||
|
## With pnpm
|
||||||
|
export LD_LIBRARY_PATH=$PWD/node_modules/.pnpm/sherpa-onnx-node@<REPLACE-THIS-WITH-THE-INSTALLED-VERSION>/node_modules/sherpa-onnx-linux-x64:$LD_LIBRARY_PATH
|
||||||
|
|
||||||
# For Linux arm64, e.g., Raspberry Pi 4
|
# For Linux arm64, e.g., Raspberry Pi 4
|
||||||
|
## With npm
|
||||||
export LD_LIBRARY_PATH=$PWD/node_modules/sherpa-onnx-linux-arm64:$LD_LIBRARY_PATH
|
export LD_LIBRARY_PATH=$PWD/node_modules/sherpa-onnx-linux-arm64:$LD_LIBRARY_PATH
|
||||||
|
## With pnpm
|
||||||
|
export LD_LIBRARY_PATH=$PWD/node_modules/.pnpm/sherpa-onnx-node@<REPLACE-THIS-WITH-THE-INSTALLED-VERSION>/node_modules/sherpa-onnx-linux-arm64:$LD_LIBRARY_PATH
|
||||||
```
|
```
|
||||||
|
|
||||||
# Examples
|
# Examples
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
const os = require('os');
|
const os = require('os');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
// Package name triggered spam for sherpa-onnx-win32-x64
|
// Package name triggered spam for sherpa-onnx-win32-x64
|
||||||
// so we have renamed it to sherpa-onnx-win-x64
|
// so we have renamed it to sherpa-onnx-win-x64
|
||||||
@@ -25,6 +26,14 @@ for (const p of possible_paths) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
|
let addon_path = `${process.env.PWD}/node_modules/sherpa-onnx-${platform_arch}`;
|
||||||
|
const pnpmIndex = __dirname.indexOf(`node_modules${path.sep}.pnpm`);
|
||||||
|
if (pnpmIndex !== -1) {
|
||||||
|
const parts = __dirname.slice(pnpmIndex).split(path.sep);
|
||||||
|
parts.pop();
|
||||||
|
addon_path = `${process.env.PWD}/${parts.join('/')}/sherpa-onnx-${platform_arch}`;
|
||||||
|
}
|
||||||
|
|
||||||
let msg = `Could not find sherpa-onnx-node. Tried\n\n ${
|
let msg = `Could not find sherpa-onnx-node. Tried\n\n ${
|
||||||
possible_paths.join('\n ')}\n`
|
possible_paths.join('\n ')}\n`
|
||||||
if (os.platform() == 'darwin' &&
|
if (os.platform() == 'darwin' &&
|
||||||
@@ -34,8 +43,7 @@ if (!found) {
|
|||||||
msg +=
|
msg +=
|
||||||
'Please remeber to set the following environment variable and try again:\n';
|
'Please remeber to set the following environment variable and try again:\n';
|
||||||
|
|
||||||
msg += `export DYLD_LIBRARY_PATH=${
|
msg += `export DYLD_LIBRARY_PATH=${addon_path}`;
|
||||||
process.env.PWD}/node_modules/sherpa-onnx-${platform_arch}`;
|
|
||||||
|
|
||||||
msg += ':$DYLD_LIBRARY_PATH\n';
|
msg += ':$DYLD_LIBRARY_PATH\n';
|
||||||
}
|
}
|
||||||
@@ -47,8 +55,7 @@ if (!found) {
|
|||||||
msg +=
|
msg +=
|
||||||
'Please remeber to set the following environment variable and try again:\n';
|
'Please remeber to set the following environment variable and try again:\n';
|
||||||
|
|
||||||
msg += `export LD_LIBRARY_PATH=${
|
msg += `export LD_LIBRARY_PATH=${addon_path}`;
|
||||||
process.env.PWD}/node_modules/sherpa-onnx-${platform_arch}`;
|
|
||||||
|
|
||||||
msg += ':$LD_LIBRARY_PATH\n';
|
msg += ':$LD_LIBRARY_PATH\n';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user