M2 Mac执行npm install报错:not found: vlc 求助
M2 Mac 下 npm install 报错找不到 vlc 的解决思路
问题背景
项目在Intel Mac上运行正常,但M2 Mac执行npm install时报错,提示找不到vlc,涉及vlc-static包。当前Node版本16.16.0、NPM版本8.11.0,已重装Node/NPM但问题依旧。
报错详情
code 1 npm ERR! path /Users/andrewleonardi/Desktop/CareerTest/CareerTest/node_modules/vlc-static npm ERR! command failed npm ERR! command sh -c node install npm ERR! /Users/andrewleonardi/Desktop/CareerTest/CareerTest/node_modules/which/which.js:10 npm ERR! Object.assign(new Error(`not found: ${cmd}`), { code: 'ENOENT' }) npm ERR! ^ npm ERR! npm ERR! Error: not found: vlc npm ERR! at getNotFoundError (/Users/andrewleonardi/Desktop/CareerTest/CareerTest/node_modules/which/which.js:10:17) npm ERR! at /Users/andrewleonardi/Desktop/CareerTest/CareerTest/node_modules/which/which.js:57:18 npm ERR! at new Promise (<anonymous>) npm ERR! at step (/Users/andrewleonardi/Desktop/CareerTest/CareerTest/node_modules/which/which.js:54:21) npm ERR! at /Users/andrewleonardi/Desktop/CareerTest/CareerTest/node_modules/which/which.js:71:22 npm ERR! at new Promise (<anonymous>) npm ERR! at subStep (/Users/andrewleonardi/Desktop/CareerTest/CareerTest/node_modules/which/which.js:69:33) npm ERR! at /Users/andrewleonardi/Desktop/CareerTest/CareerTest/node_modules/which/which.js:80:22 npm ERR! at /Users/andrewleonardi/Desktop/CareerTest/CareerTest/node_modules/isexe/index.js:42:5 npm ERR! at /Users/andrewleonardi/Desktop/CareerTest/CareerTest/node_modules/isexe/mode.js:8:5 { npm ERR! code: 'ENOENT' npm ERR! }
解决步骤
安装系统级VLC
M2 Mac默认没有预装VLC,需要手动安装:- 方式1:用Homebrew安装,终端执行
brew install vlc - 方式2:从VLC官网下载ARM架构的安装包,安装后在终端输入
vlc验证是否能正常启动(确保VLC在系统PATH中)
- 方式1:用Homebrew安装,终端执行
清理依赖缓存后重装
执行以下命令清理现有残留,再重新安装依赖:rm -rf node_modules rm package-lock.json npm cache clean --force npm install指定VLC路径(若安装后仍报错)
如果VLC已安装但vlc-static找不到,手动设置环境变量指定路径:export VLC_PATH="/Applications/VLC.app/Contents/MacOS/VLC" npm install用Rosetta 2兼容模式运行终端
找到终端应用,右键选择「显示简介」,勾选「使用Rosetta打开」,重启终端后再执行npm install,尝试绕过ARM架构兼容性问题。检查
vlc-static包兼容性
查看该包的文档或仓库,确认是否支持ARM64架构。若不支持,可寻找替代包,或考虑手动处理VLC依赖逻辑。升级Node/NPM版本
尝试升级到Node 18 LTS版本(配套NPM 9+),部分旧包在新Node版本下的ARM兼容性更好。
内容的提问来源于stack exchange,提问作者AndrewLeonardi
相关产品推荐
相关产品推荐

