Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
xuning
/
sherpaonnx
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Yongzeng Liu
2024-10-09 18:12:41 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
GitHub
2024-10-09 18:12:41 +0800
Commit
97654122fa42ec7d029f7722327ee3381d45e5e3
97654122
1 parent
d468527f
docs(nodejs-addon-examples): add guide for pnpm user (#1401)
隐藏空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
24 行增加
和
5 行删除
nodejs-addon-examples/README.md
scripts/node-addon-api/lib/addon.js
nodejs-addon-examples/README.md
查看文件 @
9765412
...
...
@@ -12,19 +12,31 @@ Note: [../nodejs-examples](../nodejs-examples) uses WebAssembly to wrap
Before you continue, please first run
```
bash
npm install
npm install
# or pnpm install
# For macOS x64
## With npm
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
## With npm
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
## With npm
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
## With npm
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
...
...
scripts/node-addon-api/lib/addon.js
查看文件 @
9765412
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
'
;
}
...
...
请
注册
或
登录
后发表评论