スキップしてメイン コンテンツに移動

[Node.js] Try node-webrtc-examples

Setup examples

First I tried building example to understand how to use WebRTC.
node-webrtc-examples - GitHub

So I cloned the repository and did "npm install".
And got error.

PS C:\Users\example\Documents\workspace\node-webrtc-examples> npm install

> canvas@2.6.1 install C:\Users\example\Documents\workspace\node-webrtc-examples\node_modules\canvas
> node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using needle for node-pre-gyp https download
node-pre-gyp WARN Pre-built binaries not installable for canvas@2.6.1 and node@13.13.0 (node-v79 ABI, unknown) (falling back to source compile with node-gyp)
node-pre-gyp WARN Hit error Remote end closed socket abruptly.
node-pre-gyp WARN Pre-built binaries not installable for canvas@2.6.1 and node@13.13.0 (node-v79 ABI, unknown) (falling back to source compile with node-gyp)
node-pre-gyp WARN Hit error ENOENT: Cannot cd into 'C:\Users\example\Documents\workspace\node-webrtc-examples\node_modules\canvas\build\Release'
Warning: Missing input files:
C:\GTK\bin\libcairo-2.dll
C:\GTK\bin\libpango-1.0-0.dll
C:\GTK\bin\libglib-2.0-0.dll
C:\GTK\bin\libfreetype-6.dll
C:\GTK\bin\libgmodule-2.0-0.dll
C:\GTK\bin\libpangocairo-1.0-0.dll
C:\GTK\bin\libgthread-2.0-0.dll
C:\GTK\bin\libgobject-2.0-0.dll
C:\GTK\bin\zlib1.dll
C:\GTK\bin\libpangowin32-1.0-0.dll
C:\GTK\bin\libfontconfig-1.dll
C:\GTK\bin\libpng14-14.dll
C:\GTK\bin\libpangoft2-1.0-0.dll
C:\GTK\bin\libintl-8.dll
C:\GTK\bin\libexpat-1.dll
Warning: Missing input files:
C:\GTK\bin\libexpat-1.dll
C:\GTK\bin\libfontconfig-1.dll
C:\GTK\bin\libpng14-14.dll
C:\GTK\bin\libgmodule-2.0-0.dll
C:\GTK\bin\libfreetype-6.dll
C:\GTK\bin\libintl-8.dll
C:\GTK\bin\libpango-1.0-0.dll
C:\GTK\bin\libglib-2.0-0.dll
C:\GTK\bin\libpangowin32-1.0-0.dll
C:\GTK\bin\zlib1.dll
C:\GTK\bin\libgobject-2.0-0.dll
C:\GTK\bin\libpangocairo-1.0-0.dll
C:\GTK\bin\libgthread-2.0-0.dll
C:\GTK\bin\libpangoft2-1.0-0.dll
C:\GTK\bin\libcairo-2.dll
Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(333,
5): error MSB3491: Could not write lines to file "Release\obj\canvas\canvas.tlog\canvas.lastbuildstate". The process ca
nnot access the file 'C:\Users\example\Documents\workspace\node-webrtc-examples\node_modules\canvas\build\Release\obj\can
vas\canvas.tlog\canvas.lastbuildstate' because it is being used by another process. [C:\Users\example\Documents\workspace
\node-webrtc-examples\node_modules\canvas\build\canvas.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Users\example\AppData\Local\Volta\tools\image\node\13.13.0\6.14.4\node_modules\npm\node_modules\node-gyp\lib\build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command 
...

I needed installing "windows-build-tools".
node.js - node-gyp installation failures on Windows - Stack Overflow

So I did "npm -g install windows-build-tools".
...And failed (2nd).

Can't do "npm -g install"

I had two problems.

One of the problem was caused by I had done by normal user.
Because Python, Build-tools of Visual Studio 2017 were also installed on installing "windows-build-tools", I had had to do by super user.

Another one was caused by using Volta.
Volta hadn't allowed "npm -g install".
PS C:\Users\example\Documents\workspace\node-webrtc-examples> npm install -g windows-build-tools
Volta error: Global package installs are not supported.

Use `volta install windows-build-tools` to add a package to your toolchain (see `volta help install` for more info).

So I did "volta install windows-build-tools".
PS C:\Users\example\Documents\workspace\node-webrtc-examples> volta install windows-build-tools
error: Package has no executables to install.

Please verify the requested package name.

...What?

Global installs done right | Volta
Volta not allowing global installs · Issue #555 · volta-cli/volta · GitHub

Should I install Node.js directly for "npm -g install"?

Play example

OK. I finally succeeded "npm install".
And no errors are occurred by "npm test".

So I do "npm start".
......and failed (3rd).

PS C:\Users\example\Documents\workspace\node-webrtc-examples> npm start

> node-webrtc-examples@0.1.0 start C:\Users\example\Documents\workspace\node-webrtc-examples
> node index.js

internal/modules/cjs/loader.js:955
  throw err;
  ^

Error: Cannot find module '../build/Release/wrtc.node'
Require stack:
- C:\Users\example\Documents\workspace\node-webrtc-examples\node_modules\wrtc\lib\binding.js
- C:\Users\example\Documents\workspace\node-webrtc-examples\node_modules\wrtc\lib\index.js
- C:\Users\example\Documents\workspace\node-webrtc-examples\lib\server\connections\webrtcconnection.js
- C:\Users\example\Documents\workspace\node-webrtc-examples\lib\server\connections\webrtcconnectionmanager.js
- C:\Users\example\Documents\workspace\node-webrtc-examples\index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:952:15)
    at Function.Module._load (internal/modules/cjs/loader.js:835:27)
    at Module.require (internal/modules/cjs/loader.js:1012:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (C:\Users\example\Documents\workspace\node-webrtc-examples\node_modules\wrtc\lib\binding.js:6:20)
    at Module._compile (internal/modules/cjs/loader.js:1123:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)
    at Module.load (internal/modules/cjs/loader.js:972:32)
    at Function.Module._load (internal/modules/cjs/loader.js:872:14)
    at Module.require (internal/modules/cjs/loader.js:1012:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\Users\\example\\Documents\\workspace\\node-webrtc-examples\\node_modules\\wrtc\\lib\\binding.js',
    'C:\\Users\\example\\Documents\\workspace\\node-webrtc-examples\\node_modules\\wrtc\\lib\\index.js',
    'C:\\Users\\example\\Documents\\workspace\\node-webrtc-examples\\lib\\server\\connections\\webrtcconnection.js',
    'C:\\Users\\example\\Documents\\workspace\\node-webrtc-examples\\lib\\server\\connections\\webrtcconnectionmanager.js',
    'C:\\Users\\example\\Documents\\workspace\\node-webrtc-examples\\index.js'
  ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-webrtc-examples@0.1.0 start: `node index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-webrtc-examples@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\example\AppData\Roaming\npm-cache\_logs\2020-04-25T11_08_10_012Z-debug.log

I thought this example also supported ver.13 as same as node-webrtc.
But actually it supported only ver.12 or earlier versions.

The error was same as this issue.
Error: Cannot find module '../build/Release/wrtc.node' · Issue #3 · geckosio/phaser3-multiplayer-game-example · GitHub

So I installed ver.12 and pinned it.
After re-installing node_modules, I could "npm start".


コメント

このブログの人気の投稿

[Nest.js] Show static files

Intro I wanted to use Nest.js and WebRTC(node-webrtc). NestJS - A progressive Node.js framework Documentation | NestJS - A progressive Node.js framework And because I wanted to try with simple page(not use JavaScript frameworks), I added static HTML, CSS, JavaScript into a Nest.js project. Prepare Install First, I installed @nestjs/cli. First steps | NestJS - A progressive Node.js framework As same as last time , I couldn't do global install because I had used Volta. But I could installed by volta. volta install @nestjs/cli Create project nest new nest-web-rtc-sample volta pin node@12 Run npm start After doing "npm start", I could getting "Hello World!" from http://localhost:3000. Add static files I could add static files by two ways. @nestjs/serve-static First one of them was using "serve-static". Serve Static | NestJS - A progressive Node.js framework npm install --save @nestjs/serve-static And I needed adding a module into app.modu

[Angular][ASP.NET Core] Upload chunked files

Intro I wanted to send files to Web application (made by ASP.NET Core). If the file size had been small, I didn't need do any special things. But when I tried to send a large file, the error was occurred by ASP.NET Core's limitation. Though I could change the settings, but I didn't want to do that, because I hadn't known the file sizes what would been actually using. So I splitted the data into chunks first, and sent them. After receiving all chunks, I merged them into one file. There might be some libraries or APIs (ex. Stream API) what did them automatically, but I couldn't find them. What I did [ASP.NET Core] Make CORS enabled [Angular] Split a large file into chunks [Angular][ASP.NET Core] Send and receive data as form data [ASP.NET Core] Merge chunks into one file [ASP.NET Core] Make CORS enabled Because the client side application(Angular) and the server side application(ASP.NET Core) had been separated, I had to make CORS(Cross-Origin Requests)

[Nest.js] Use WebSocket with ws

Intro Until last time , I had used node-web-rtc to try WebRTC. But because the example was a little complicated for I understood the core functions of using WebRTC. So I look for other frameworks or libraries. PeerJS is a famous library for WebRTC. peers/peerjs: Peer-to-peer data in the browser. - GitHub peers/peerjs-server: Server for PeerJS - GitHub PeerJS - Simple peer-to-peer with WebRTC A problem is I don't know how to integrate to the Nest.js project. I couldn't find examples. So I don't choose at least this time. What shall I choose? According MDN, WebRTC doesn't specify strictly what technology is used on server application for connecting two devices. Signaling and video calling - Web APIs | MDN But in many examples include MDN's one use WebSocket. samples-server/s/webrtc-from-chat at master · mdn/samples-server · GitHub So I try WebSocket in the Nest.js project. Use WebSocket in a Nest.js project Nest.js has a function for using We