安装Edge Impulse CLI时遇到的“sharp”模块安装失败

Node.js安装完毕后,以管理员身份运行命令提示符,执行 npm install -g edge-impulse-cli --force --verbose,报错日志节选:

npm warn cleanup   [
npm warn cleanup     '\\\\?\\C:\\Users\\15288\\AppData\\Roaming\\npm\\node_modules\\edge-impulse-cli\\node_modules\\sharp',
npm warn cleanup     [Error: EPERM: operation not permitted, rmdir 'C:\Users\15288\AppData\Roaming\npm\node_modules\edge-impulse-cli\node_modules\sharp\node_modules'] {
npm warn cleanup       errno: -4048,
npm warn cleanup       code: 'EPERM',
npm warn cleanup       syscall: 'rmdir',
npm warn cleanup       path: 'C:\\Users\\15288\\AppData\\Roaming\\npm\\node_modules\\edge-impulse-cli\\node_modules\\sharp\\node_modules'
npm warn cleanup     }
npm warn cleanup   ],
npm warn cleanup   [
npm warn cleanup     '\\\\?\\C:\\Users\\15288\\AppData\\Roaming\\npm\\node_modules\\edge-impulse-cli\\node_modules\\@aws-sdk\\middleware-sdk-s3',
npm warn cleanup     [Error: EPERM: operation not permitted, rmdir 'C:\Users\15288\AppData\Roaming\npm\node_modules\edge-impulse-cli\node_modules\@aws-sdk\middleware-sdk-s3\node_modules\@aws-sdk\core\dist-types\ts3.4\submodules\protocols'] {
npm warn cleanup       errno: -4048,
npm warn cleanup       code: 'EPERM',
npm warn cleanup       syscall: 'rmdir',
npm warn cleanup       path: 'C:\\Users\\15288\\AppData\\Roaming\\npm\\node_modules\\edge-impulse-cli\\node_modules\\@aws-sdk\\middleware-sdk-s3\\node_modules\\@aws-sdk\\core\\dist-types\\ts3.4\\submodules\\protocols'
npm warn cleanup     }
npm warn cleanup   ]
npm warn cleanup ]
npm verbose stack Error: command failed
npm verbose stack     at promiseSpawn (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\promise-spawn\lib\index.js:22:22)
npm verbose stack     at spawnWithShell (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\promise-spawn\lib\index.js:124:10)
npm verbose stack     at promiseSpawn (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\promise-spawn\lib\index.js:12:12)
npm verbose stack     at runScriptPkg (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\run-script\lib\run-script-pkg.js:77:13)
npm verbose stack     at runScript (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\run-script\lib\run-script.js:9:12)
npm verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\rebuild.js:329:17
npm verbose stack     at run (C:\Program Files\nodejs\node_modules\npm\node_modules\promise-call-limit\dist\commonjs\index.js:67:22)
npm verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\promise-call-limit\dist\commonjs\index.js:84:9
npm verbose stack     at new Promise (<anonymous>)
npm verbose stack     at callLimit (C:\Program Files\nodejs\node_modules\npm\node_modules\promise-call-limit\dist\commonjs\index.js:35:69)
npm verbose pkgid sharp@0.32.6
npm error code 1
npm error path C:\Users\15288\AppData\Roaming\npm\node_modules\edge-impulse-cli\node_modules\sharp
npm error command failed
npm error command C:\WINDOWS\system32\cmd.exe /d /s /c (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)
npm error sharp: Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.14.5/libvips-8.14.5-win32-x64.tar.br
npm error sharp: Please see https://sharp.pixelplumbing.com/install for required dependencies
npm error sharp: Installation error: Request timed out

解决方案

1. 强制清理全局残留(管理员CMD)

rmdir /s /q "%APPDATA%\npm\node_modules\edge-impulse-cli"
npm cache clean --force

 2. 配置镜像源加速(避免GitHub直)

# 设置环境变量(作用于当前终端会话,关闭终端失效)
set SHARP_BINARY_HOST=https://npmmirror.com/mirrors/sharp
set SHARP_LIBVIPSHOST=https://npmmirror.com/mirrors/sharp-libvips

3. 执行安装

#--sharp_xxx=... 仅当前命令生效,确保即使环境变量未生效,命令行参数也能覆盖
npm install -g edge-impulse-cli --force --verbose --sharp_binary_host=https://npmmirror.com/mirrors/sharp --sharp_libvips_binary_host=https://npmmirror.com/mirrors/sharp-libvips

4.验证安装

edge-impulse-blocks --version
# 预期输出:1.17.0(或其他版本号)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值