Why is there an error when running the command "npm i mediasoup@3" error on windows?

Trying to install the mediasoup library on a Windows machine via:

npm install mediasoup@3

The app that needs this library is being developed on a MacOS machine and works fine when being installed. The live app will be hosted on a Windows Server.

When running the command in an empty npm folder on the Windows machine, it returns the following error.

npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm ERR! code 1
npm ERR! path D:\hostingspaces\test\livebidding\node_modules\mediasoup
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node npm-scripts.js postinstall
npm ERR! npm-scripts.js [INFO] running task "postinstall"
npm ERR! npm-scripts.js [INFO] executing command: node npm-scripts.js worker:build
npm ERR! npm-scripts.js [INFO] running task "worker:build"
npm ERR! npm-scripts.js [INFO] executing command: make -C worker
npm ERR! make: Entering directory 'D:/hostingspaces/test/livebidding/node_modules/mediasoup/worker'
npm ERR! # Updated pip and setuptools are needed for meson
npm ERR! make: Leaving directory 'D:/hostingspaces/test/livebidding/node_modules/mediasoup/worker'
npm ERR! process_begin: CreateProcess(NULL, dirname D:/hostingspaces/test/livebidding/node_modules/mediasoup/worker/Makefile, ...) failed.
npm ERR! Makefile:7: pipe: No error
npm ERR! process_begin: CreateProcess(NULL, pwd, ...) failed.
npm ERR! Makefile:37: pipe: No error
npm ERR! process_begin: CreateProcess(NULL, pwd, ...) failed.
npm ERR! Makefile:56: pipe: No error
npm ERR! The system cannot find the path specified.
npm ERR! process_begin: CreateProcess(NULL, pwd, ...) failed.
npm ERR! Makefile:62: pipe: Bad file descriptor
npm ERR! The system cannot find the path specified.
npm ERR! process_begin: CreateProcess(NULL, pwd, ...) failed.
npm ERR! Makefile:62: pipe: Bad file descriptor
npm ERR! The system cannot find the path specified.
npm ERR! process_begin: CreateProcess(NULL, pwd, ...) failed.
npm ERR! Makefile:65: pipe: Bad file descriptor
npm ERR! '[' is not recognized as an internal or external command,
npm ERR! operable program or batch file.
npm ERR! process_begin: CreateProcess(NULL, pwd, ...) failed.
npm ERR! Makefile:28: pipe: Bad file descriptor
npm ERR! process_begin: CreateProcess(NULL, # Updated pip and setuptools are needed for meson, ...) failed.
npm ERR! make (e=2): The system cannot find the file specified.
npm ERR! make: *** [Makefile:57: meson-ninja] Error 2

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Administrator\AppData\Local\npm-cache\_logs\2022-03-08T11_27_43_896Z-debug.log

I have node, python, pip, and GNU make installed on the machine.

Is there something else that needs to be configured or why is this error being shown?

Please read the docs first: mediasoup :: Installation

I have followed the installation guide to get to this point and this is the error I am still getting.

According to logs you don’t have correct Make version, which in turn means you didn’t follow all installation instructions :disappointed:

By the way, if there is already a Make at the location that is in the PATH, then it will continue to run even if the instructions are followed, and Msys folder is appended to the end of the PATH.

I feel this topic comes up too much, is there a possibility someone with a clean install of windows could walk us through from which applications to use/what to install, how to install.

Would make for great documentation and a mass majority of users use windows but don’t understand these steps clearly. I certainly don’t use windows or I would help lots but if someone can cover this in a new post I’m sure it’d be widely used!!!

1 Like

Longer term solution would be to have Replace Makefile with Python script · Issue #701 · versatica/mediasoup · GitHub to reduce dependencies, then just Node.js and Python would be required. But no one volunteered yet and I wasn’t in a mood either :slightly_smiling_face:

Wouldn’t it be easier, at least for the time being, just to use a Python script to download all necessary MSYS files to a temporary folder during installation? For example, this one downloads and extracts MSYS and make to the current folder:

import io, tarfile, urllib.request

def get(url):
  tar = tarfile.open(fileobj=io.BytesIO(urllib.request.urlopen(url).read()))
  tar.extractall()
  tar.close()

try:  
  get('https://sourceforge.net/projects/mingw/files/MSYS/Base/msys-core/msys-1.0.19-1/msysCORE-1.0.19-1-msys-1.0.19-bin.tar.xz/download')
  get('https://sourceforge.net/projects/mingw/files/MSYS/Base/libiconv/libiconv-1.14-1/libiconv-1.14-1-msys-1.0.17-dll-2.tar.lzma/download')
  get('https://sourceforge.net/projects/mingw/files/MSYS/Base/gettext/gettext-0.18.1.1-1/libintl-0.18.1.1-1-msys-1.0.17-dll-8.tar.lzma/download')
  get('https://sourceforge.net/projects/mingw/files/MSYS/Base/coreutils/coreutils-5.97-3/coreutils-5.97-3-msys-1.0.13-bin.tar.lzma/download')
  get('https://sourceforge.net/projects/mingw/files/MSYS/Base/make/make-3.81-3/make-3.81-3-msys-1.0.13-bin.tar.lzma/download')
except Exception as err:
  print('MSYS/make download error: ', err)

That is an interesting hack, the challenge is we need to do it before calling makefile and all commands are done using said makefile :upside_down_face:

But we have npm-scripts.js. Suppose this script is in the worker/scripts/getmake.py:

import io, tarfile, urllib.request

def get(url):
  tar = tarfile.open(fileobj=io.BytesIO(urllib.request.urlopen(url).read()))
  tar.extractall('worker/out/msys')
  tar.close()

get('https://sourceforge.net/projects/mingw/files/MSYS/Base/msys-core/msys-1.0.19-1/msysCORE-1.0.19-1-msys-1.0.19-bin.tar.xz/download')
get('https://sourceforge.net/projects/mingw/files/MSYS/Base/libiconv/libiconv-1.14-1/libiconv-1.14-1-msys-1.0.17-dll-2.tar.lzma/download')
get('https://sourceforge.net/projects/mingw/files/MSYS/Base/gettext/gettext-0.18.1.1-1/libintl-0.18.1.1-1-msys-1.0.17-dll-8.tar.lzma/download')
get('https://sourceforge.net/projects/mingw/files/MSYS/Base/coreutils/coreutils-5.97-3/coreutils-5.97-3-msys-1.0.13-bin.tar.lzma/download')
get('https://sourceforge.net/projects/mingw/files/MSYS/Base/make/make-3.81-3/make-3.81-3-msys-1.0.13-bin.tar.lzma/download')

Then in npm-scripts.js:

if (isWindows)
{
  const { spawnSync } = require('child_process');
  var res = spawnSync('where', [ 'python3.exe' ]);
  if (res.status !== 0)
  {
    res = spawnSync('where', [ 'python.exe' ]);
    if (res.status !== 0)
    {
      console.log('Cannot find Python executable.');
      process.exit(1);
    }
  }
  execute(`${String(res.stdout).trim()} worker\\scripts\\getmake.py`);
  process.env['PATH'] = process.cwd() + '\\worker\\out\\msys\\bin;' + process.env['PATH'];
}

And we have the correct version of make locally.

I’ll have to replicate all that in Rust as well. Could be a short-term option. Feel free to contribute.

It turned out that a couple more files from MSYS were necessary for Meson, but all in all it worked pretty well. I’ll leave it as a PR in case someone is interested: Download and use MSYS/make locally for Windows postinstall by snnz · Pull Request #792 · versatica/mediasoup · GitHub

I have an similar error, it is definetly a wrong make version ? I installed the gnu make from the installation page and put the bin folder to the path variable.

Installation instructions tell you which version of make to install. They are, for some reason, all slightly different and not always compatible.

I dont see there which version i should use. I am on windows and dowlnoaded the gnu make from the link in the instructions. But i also tried with other make versions and same error

Another error, i have now:


my make verson

No need to try another make. Just install one provided in docs and make sure to add to PATH as in instructions too and it’ll work.

2 Likes

As i said, i installed the make version from the link on the installation page (MinGW - Minimalist GNU for Windows download | SourceForge.net)
I also added C:\MinGW\msys\1.0\bin, which is the right location on my computer to PATH variable

This is correct, what is the latest error you’re getting?