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

投稿

4月, 2020の投稿を表示しています

[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

[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

[Volta] Manage Node.js version on Windows

Intro I have installed Node.js directolly on Windows. https://nodejs.org/en/ And I installed Node.js ver.14.0.0 in these days. After installing, I tried to install node-webrtc and failed because it hadn't supported Node.js ver.14 yet(2020-04-25). node-webrtc - GitHub So I must use ver.13. But I want to use latest version if I can. Thus, I start searching Node.js version manager for Windows. Select version manager I choosed n for Ubuntu. n - GitHub But it doesn't support Windows. One of famous Node.js version manager for Windows is nvm-windows. nvm-windows - GitHub Set up NodeJS on native Windows | Microsoft Docs I'm afraid the development isn't active because the last release date is 2018-08-02. Finally, I choosed Volta. Volta - Start your engines. volta - GitHub It is introduced the Microsoft Docs above as alternative version manager. Because I have already set Developer Mode on Windows, so I just install by its installer. Use Volta I c

[Angular] Upgrade from 8 to 9 and set basehref

Upgrade from 8 to 9 I have had a question. Though I often executed "npm -g update" and Angular ver.9 has already been released, but Angular version in my PC is still 8. Why? Finally I got the reason. I must install @angular/cli again. npm install -g @angular/cli It's same as updating NuGet packages. After installing, I just do "ng update @angular/cli @angular/core" on my project. Angular Update Guide set basehref Because I use IIS, base url becomes like "http://localhost:5000/sample". So when I build Angular product, I must add path to index.html like below. index.html <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Sample</title> <base href=""> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="icon" type="image/x-icon" href=" sample/ favicon.ico"

[TypeScript] How to use "type"

Intro When I write codes, I often confuse if I should use type alias or interface. Actually, they are quite similar in some situations. So I want to know how to distinct them. Environments TypeScript ver.3.8.3 Node.js ver.12.10.0 Similarity After compiling Both type alias and interface are only in TypeScript. After compiling to JavaScript, they will be disappeared. TypeScript interface ISample{ name: string; } type TSample = { message: string }; function main() { const iSample: ISample = { name: 'Hello' }; const tSample: TSample = { message: 'World' }; } main(); JavaScript "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function main() { var iSample = { name: 'Hello' }; var tSample = { message: 'World' }; } main(); Treat as same type If an object has same properties with them, they treat as their type, though the object d

[ASP.NET Web Forms][TypeScript] Send data, call functions

Intro Recently, I often update ASP.NET Web Forms application in my work. Because Web Forms won't be supported in .NET 5, so I want to replace them into MVC. Introducing .NET 5 | .NET Blog I hope I can rebuild the projects from the beginning, but it's a little difficult. The reasons are like the bugets, there are many "Big ball of mud", and so on. So now, I try to organize to reduce burden for replace in the future. This time, to change from Web Forms to HTML(reduce the Web Forms functions from View), I try to interact between Web Forms(+ code behind) and TypeScript. Environments ASP.NET ver.4.5.2 TypeScript ver.3.8.3 webpack ver.4.42.1 package.json { "scripts": { "webpack": "npx webpack -w" }, "dependencies": { "rxjs": "^6.5.4", "ts-loader": "^6.2.2", "tsc": "^1.20150623.0", "typescript": "^3.8.3", "we

[Ubuntu] Install Docker, PostgreSQL(From DockerHub), PgAdmin4 + SELECT ALL

Intro I build development of PostgreSQL environment on Ubuntu this time. Because I haven't wanted to install PostgreSQL directly, I use Docker to install it. After installing them, I will try some SQL. Build development environments Docker According to the documents, I add repository and install "docker-ce", "docker-ce-cli", "containerd.io" Get Docker Engine - Community for Ubuntu | Docker Documentation When I had installed "Docker for Windows" on Windows, it had the GUI application. But maybe there is no GUI application for Ubuntu or I need installing another package? PostgreSQL(Docker Hub) Because I have wanted to use latest version, I just do "docker pull postgres". postgres - Docker Hub After getting PostgreSQL, I made mistake when I did "docker run". docker run (failed) docker run --name sample-shop -e POSTGRES_PASSWORD=postgres -d postgres -p 5432:5432 There are no any errors, but I can't access to