Skip to content

Windowsセットアップマニュアル

Koki Takahashi edited this page Apr 25, 2024 · 3 revisions

node-canvasを動かすために特別なセットアップ手順が必要です。PowerShell (管理者権限は不要) で以下を実行。

# Git・Node.jsをセットアップ

# WinGetでnode-gypの依存ソフトウェアをインストール
# Ref: https://github.com/nodejs/node-gyp?tab=readme-ov-file#on-windows
# Ref: https://gist.github.com/robotdad/83041ccfe1bea895ffa0739192771732
winget install Python.Python.3.12
winget install Microsoft.VisualStudio.2022.Community --override "--wait --quiet --add ProductLang En-us --add Microsoft.VisualStudio.Workload.NativeDesktop --includeRecommended"

# VSSetupをインストール
# 確認を2回求められるので両方に「y」と答えてください。
# Ref: https://github.com/nodejs/node-gyp?tab=readme-ov-file#on-windows
Install-Module VSSetup -Scope CurrentUser

# node-gypをインストール
# Ref: https://github.com/nodejs/node-gyp?tab=readme-ov-file#installation
npm install -g node-gyp@8

# node-canvasの依存ソフトウェアをインストール
# Ref: https://github.com/Automattic/node-canvas/wiki/Installation:-Windows#install-manually
# Ref: https://github.com/Automattic/node-canvas/blob/v2.11.2/.github/workflows/ci.yaml#L44
Invoke-WebRequest "https://ftp-osl.osuosl.org/pub/gnome/binaries/win64/gtk+/2.22/gtk+-bundle_2.22.1-20101229_win64.zip" -OutFile "gtk.zip"
Expand-Archive gtk.zip -DestinationPath "C:\GTK"
Invoke-WebRequest "https://downloads.sourceforge.net/project/libjpeg-turbo/2.0.4/libjpeg-turbo-2.0.4-vc64.exe" -OutFile "libjpeg.exe" -UserAgent NativeHost
.\libjpeg.exe /S

# ここで再起動 (本当に必要? 要検証)

# slackbotをクローンする
git clone --recursive https://github.com/tsg-ut/slackbot.git
cd slackbot

# slackbotの依存ソフトウェアをインストール
npm install

# .envを作成
cp .env.example .env
vi .env

# slackbotを開発者モードで起動
npm run dev

Clone this wiki locally