media-soup-demo 跑通过程记录

1,033 阅读3分钟

主要就是准备好前置软件安装,版本要正确,文件夹权限要给,这个包超级大要有耐心,安不上换yarn。

Git地址:github.com/versatica/m…

$ git clone https://github.com/versatica/mediasoup-demo.git
$ cd mediasoup-demo
$ git checkout v3

MAC电脑内置了GNU make,我的Node版本是v16.19.1,只需要安装python3,在python官网www.python.org/ 下载安装就好了。

cd server
npm install

这一步需要文件夹访问权限,不能简单的sudo su,因为不是一个账户,不是同一个ssh配置。

sudo chown -R 501:20 "/Users/a1234/.npm"

之后npm i 又报错

npm ERR! <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)>

这个错误表明在执行 npm inpm install 命令时出现了 SSL 证书验证失败的问题 先升级一下pip pip install --upgrade pip setuptools

python3 -m pip install --upgrade meson ninja

之后进到python文件夹

cd /Applications/Python\ 3.10
sudo ./Install\ Certificates.Command

之后我看运行的太慢了就停止换源重新运行了,结果报错:

npm ERR! code ENOTEMPTY
npm ERR! syscall rename
npm ERR! path /Users/a1234/Documents/tisi/doc/rtmp-demo/mediasoup-demo/server/node_modules/ajv
npm ERR! dest /Users/a1234/Documents/tisi/doc/rtmp-demo/mediasoup-demo/server/node_modules/.ajv-KCUcDysN
npm ERR! errno -66
npm ERR! ENOTEMPTY: directory not empty, rename '/Users/a1234/Documents/tisi/doc/rtmp-demo/mediasoup-demo/server/node_modules/ajv' -> '/Users/a1234/Documents/tisi/doc/rtmp-demo/mediasoup-demo/server/node_modules/.ajv-KCUcDysN'

npm ERR! A complete log of this run can be found in: /var/root/.npm/_logs/2023-07-02T13_22_23_573Z-debug-0.log

该错误消息表示在执行npm install命令时发生了一个错误。具体错误是ENOTEMPTY: directory not empty,即目录不为空,无法进行重命名操作。删除对应目录,删除缓存重新跑。

之后报错:

npm install mediasoup
npm ERR! code 128
npm ERR! An unknown git error occurred
npm ERR! command git --no-replace-objects ls-remote ssh://git@github.com/versatica/mediasoup.git
npm ERR! fatal: unable to access 'https://github.com/versatica/mediasoup.git/': Failed to connect to github.com port 443 after 21365 ms: Couldn't connect to server

npm ERR! A complete log of this run can be found in: /var/root/.npm/_logs/2023-07-02T15_01_01_225Z-debug-0.log

执行ssh -T git@github.com发现没有git的ssh配置信息,进而发现自己在sudo su里!!!退出sudo,再执行,报错还是权限问题,再把权限配置一下执行,执行成功了,但是有一些依赖没有完全安装:

33 packages are looking for funding
  run `npm fund` for details

17 vulnerabilities (11 moderate, 6 high)

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.

执行npm audit fix,报错:

a1234@MacBook-Pro server % npm audit fix
npm ERR! code ENOLOCK
npm ERR! audit This command requires an existing lockfile.
npm ERR! audit Try creating one first with: npm i --package-lock-only
npm ERR! audit Original error: loadVirtual requires existing shrinkwrap file

npm ERR! A complete log of this run can be found in: /Users/a1234/.npm/_logs/2023-07-02T15_39_31_639Z-debug-0.log

是没有有效的 lockfile 文件,生成lock文件: npm i --package-lock-only再运行npm audit fix 最后就是这个报错了:

a1234@MacBook-Pro app % npm install                                           
npm ERR! code EINVALIDTAGNAME
npm ERR! Invalid tag name ">=^16.0.0" of package "react@>=^16.0.0": Tags may not have any characters that encodeURIComponent encodes.

npm ERR! A complete log of this run can be found in: /Users/a1234/.npm/_logs/2023-07-02T15_53_11_951Z-debug-0.log

我试过了清除重新跑,或者单独安装React,换源,关闭打开VPN,还有npm install --legacy-peer-deps。 没啥好办法,其他人同样的node,npm版本成功了,我最后改用yarn成功了。

之后就是配openSSL:

  1. 运行以下 OpenSSL 命令生成私钥文件(key.pem):

    csharpCopy code
    openssl genpkey -algorithm RSA -out key.pem
    
  2. 运行以下 OpenSSL 命令生成自签名证书请求文件(csr.pem):

    vbnetCopy code
    openssl req -new -key key.pem -out csr.pem
    

    在运行此命令时,您将被要求提供有关证书的一些信息,例如组织名称、通用名称(域名)、城市等。

  3. 运行以下 OpenSSL 命令生成自签名证书文件(cert.pem):

    csharpCopy code
    openssl x509 -req -days 365 -in csr.pem -signkey key.pem -out cert.pem
    

    这将生成有效期为 365 天的自签名证书文件。

之后按照文档跑就行了。这个流媒体服务器在国内的资料非常少。磨了一天才调通。