docs(nodejs-addon-examples): add guide for pnpm user (#1401)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
|
||||
// Package name triggered spam for sherpa-onnx-win32-x64
|
||||
// so we have renamed it to sherpa-onnx-win-x64
|
||||
@@ -25,6 +26,14 @@ for (const p of possible_paths) {
|
||||
}
|
||||
|
||||
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 ${
|
||||
possible_paths.join('\n ')}\n`
|
||||
if (os.platform() == 'darwin' &&
|
||||
@@ -34,8 +43,7 @@ if (!found) {
|
||||
msg +=
|
||||
'Please remeber to set the following environment variable and try again:\n';
|
||||
|
||||
msg += `export DYLD_LIBRARY_PATH=${
|
||||
process.env.PWD}/node_modules/sherpa-onnx-${platform_arch}`;
|
||||
msg += `export DYLD_LIBRARY_PATH=${addon_path}`;
|
||||
|
||||
msg += ':$DYLD_LIBRARY_PATH\n';
|
||||
}
|
||||
@@ -47,8 +55,7 @@ if (!found) {
|
||||
msg +=
|
||||
'Please remeber to set the following environment variable and try again:\n';
|
||||
|
||||
msg += `export LD_LIBRARY_PATH=${
|
||||
process.env.PWD}/node_modules/sherpa-onnx-${platform_arch}`;
|
||||
msg += `export LD_LIBRARY_PATH=${addon_path}`;
|
||||
|
||||
msg += ':$LD_LIBRARY_PATH\n';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user