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

[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".


コメント

このブログの人気の投稿

[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] 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] Sending file with Observable and showing loading screen

Intro When I tried sending file data on last time, I had confused with "promise.then", "async/await" and "Observable". [Angular][ASP.NET Core] Upload chunked files So I wanted to distinct them, and this time, I tried to use "Observable" because HttpClient return Observable<any>. Call observables in order I sended file in these steps. Read file by FileReader Create directory for saving chunks send and saving chunks merge chunks to one file and delete chunks Each steps used the former steps result. So I could write by Promise.then like below. this.executeStep1() // return Promise<UploadResult> .then(result => this.executeStep2(result)) // return Promise<UploadResult> .then(result => this.executeStep3(result)) // return Promise<UploadResult> .catch(reason => console.log(reason)); Result I could write with pipe & flatMap. file-uploader.service.ts public upload(file: File): Observable<U...