Windows环境下mediasoup安装失败(meson相关npm错误)求助
Fixing mediasoup Installation Failure on Windows
First, let's look at the error log you're encountering:
npm ERR! code 1 npm ERR! path C:\Users\USER\Documents\video-conferencing\node_modules\mediasoup npm ERR! 命令执行失败 npm ERR! 命令:C:\WINDOWS\system32\cmd.exe /d /s /c node npm-scripts.js postinstall npm ERR! npm-scripts.js [INFO] 正在执行任务"postinstall" npm ERR! npm-scripts.js [INFO] 执行命令:node npm-scripts.js worker:build npm ERR! npm-scripts.js [INFO] 正在执行任务"worker:build" npm ERR! npm-scripts.js [INFO] 执行命令:make -C worker npm ERR! # meson需要更新后的pip和setuptools npm ERR! make: 离开目录 `/c/Users/USER/Documents/video-conferencing/node_modules/mediasoup/worker' npm ERR! make: dirname: 未找到命令 npm ERR! make: 进入目录 `/c/Users/USER/Documents/video-conferencing/node_modules/mediasoup/worker' npm ERR! make: pwd: 未找到命令 npm ERR! make: pwd: 未找到命令 npm ERR! make: /bin/sh: 未找到命令 npm ERR! make: pwd: 未找到命令 npm ERR! make: /bin/sh: 未找到命令 npm ERR! make: pwd: 未找到命令 npm ERR! make: /bin/sh: 未找到命令 npm ERR! make: pwd: 未找到命令 npm ERR! make: /bin/sh: 未找到命令 npm ERR! make: pwd: 未找到命令 npm ERR! make: /bin/sh: 未找到命令 npm ERR! make: *** [meson-ninja] 错误 127
What's causing this?
Errors like dirname: command not found, pwd: command not found, and /bin/sh: command not found mean your Windows environment lacks a Unix-like toolchain. mediasoup's Worker component is written in C++ and relies on tools like make, bash, and standard Unix commands to compile—these aren't available in the default Windows CMD or PowerShell.
Step-by-Step Solutions
Option 1: Use WSL2 (Recommended for Stability)
WSL2 provides a full Linux environment within Windows, which is the most reliable way to build mediasoup:
- Open PowerShell as Administrator, run:
wsl --install - Follow the prompts to restart your PC and install the default Linux distro (usually Ubuntu).
- Launch WSL, navigate to your project directory (WSL maps your Windows C: drive to
/mnt/c/, so your path would be/mnt/c/Users/USER/Documents/video-conferencing/). - First install the required build dependencies in WSL:
sudo apt update sudo apt install -y build-essential python3-pip ninja-build meson - Clean up any failed install files and re-run npm:
rm -rf node_modules package-lock.json npm install
Option 2: Use Git Bash (Lightweight Alternative)
If you don't want to set up WSL, Git Bash offers a minimal Unix-like environment:
- Download and install Git for Windows (make sure to check "Git Bash Here" and "Add Git to PATH" during setup).
- Right-click your project folder and select "Git Bash Here".
- Install the necessary tools (Git Bash uses MSYS2 under the hood):
pacman -S base-devel python3-pip ninja meson - Clean up and reinstall:
rm -rf node_modules package-lock.json npm install
Key Notes
- Don't run
npm installfor mediasoup directly in Windows CMD/PowerShell—it won't have the required Unix tools. - If using WSL, consider moving your project to the WSL file system (e.g.,
~/projects/video-conferencing/) instead of the mounted Windows drive for better performance.
内容的提问来源于stack exchange,提问作者Dunkwu Alex
相关产品推荐
相关产品推荐

