はじめに
DockerのSFDX開発環境にLWC ローカル開発サーバをインストールする。
通常sfdxコマンドからプラグインをインストールだけだが、事前に必要なモジュールがいくつかあり調査したので、備忘録として残しておく。
前準備
開発環境
- 前準備の項を参照
- 利用イメージ
インストール
エラーも一部抜粋して記載
lwc-dev-serverをインストール
$ sfdx plugins:install @salesforce/lwc-dev-server (中略) Please make sure you are using a supported platform and node version. If you would like to compile fibers on this machine please make sure you have setup your build environment-- Windows + OS X instructions here: https://github.com/nodejs/node-gyp Ubuntu users please run: `sudo apt-get install g++ build-essential` RHEL users please run: `yum install gcc-c++` and `yum groupinstall 'Development Tools'` Alpine users please run: `sudo apk add python make g++` /bin/sh: 1: nodejs: not found
モジュールがインストールされていないため、エラーとなる。 Dockerイメージのディストリビューションを調べる。
$ cat /etc/os-release NAME="Ubuntu" VERSION="20.04.5 LTS (Focal Fossa)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 20.04.5 LTS" VERSION_ID="20.04" HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" VERSION_CODENAME=focal UBUNTU_CODENAME=focal
Ubuntuなので、メッセージ通りのコマンドを実行する。
$ apt-get update $ apt-get install g++ build-essential
再度インストールを実行する。
$ sfdx plugins:install @salesforce/lwc-dev-server
完了。
ローカルサーバの実行
サーバが起動すると、自動でポートも開く。サーバを停止すれば、ポートも閉じる。すげー。
# CLIからの実行 $ sfdx force:lightning:lwc:start
まとめ
公式DockerイメージはUbuntuなので、以下のコマンドをする。
$ apt-get update $ apt-get install g++ build-essential $ sfdx plugins:install @salesforce/lwc-dev-server