ElectronをMacにインストールする方法

  1. node.js をインストールする
  2. Electron をインストールする
  • HomeBrew の brew コマンドを使って、node.js をインストールします。
    % brew install node

    を実行します。

% brew install node
 
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 2 taps (homebrew/cask, homebrew/core).
==> New Formulae
python-yq
==> Updated Formulae
readline ✔              cimg                    exploitdb               hevea                   lynis                   php-cs-fixer            swiftformat
adr-tools               clingo                  faas-cli                hlint                   memcached               protobuf@2.6            telegraf
annie                   clojurescript           flow                    hub                     menhir                  py2cairo                terragrunt
ansible                 conan                   flyway                  hugo                    mill                    py3cairo                the_platinum_searcher
apache-opennlp          convox                  fmt                     hyperscan               mkcert                  quicktype               tox
ark                     creduce                 folly                   imagemagick             mkdocs                  rabbitmq                txr
aws-elasticbeanstalk    csvkit                  fuseki                  imagemagick@6           node                    rancher-cli             uwsgi
b2-tools                cython                  get_iplayer             jenkins                 ntl                     rocksdb                 vim
baresip                 darksky-weather         gmt                     jhipster                octave                  roll                    vowpal-wabbit
bats-core               diffoscope              gnatsd                  landscaper              openapi-generator       s3fs                    wandio
bgpstream               dlib                    gobuster                libgit2                 opencv                  scour                   webpack
cake                    dynare                  goreleaser              libqalculate            opendetex               sfk                     wine
cargo-completion        emscripten              gron                    libtrace                osquery                 sshrc                   wireguard-tools
ceres-solver            ephemeralpg             hadolint                linkerd                 percona-toolkit         suite-sparse            wtf
cfr-decompiler          ethereum                hana                    llvm                    pgloader                sundials                xonsh
==> Renamed Formulae
saltstack -> salt
==> Deleted Formulae
artifactory-cli-go                                                                   wry
 
==> Installing dependencies for node: icu4c
==> Installing node dependency: icu4c
==> Downloading https://homebrew.bintray.com/bottles/icu4c-62.1.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring icu4c-62.1.sierra.bottle.tar.gz
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local,
because macOS provides libicucore.dylib (but nothing else).
 
If you need to have this software first in your PATH run:
  echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.zshrc
  echo 'export PATH="/usr/local/opt/icu4c/sbin:$PATH"' >> ~/.zshrc
 
For compilers to find this software you may need to set:
    LDFLAGS:  -L/usr/local/opt/icu4c/lib
    CPPFLAGS: -I/usr/local/opt/icu4c/include
For pkg-config to find this software you may need to set:
    PKG_CONFIG_PATH: /usr/local/opt/icu4c/lib/pkgconfig
 
==> Summary
🍺  /usr/local/Cellar/icu4c/62.1: 250 files, 67.3MB
==> Installing node
==> Downloading https://homebrew.bintray.com/bottles/node-10.6.0.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring node-10.6.0.sierra.bottle.tar.gz
==> Caveats
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d
==> Summary
🍺  /usr/local/Cellar/node/10.6.0: 6,793 files, 60MB
  • インストールが正常に完了したかどうか確認するには、which コマンドを使って、node と npm にパスが通っているか確認します。
% which node
/usr/local/bin/node
% which npm
/usr/local/bin/npm

正常にインストールが完了していれば上記のように、node と npm のパスが表示されます。

  • 次に、Electron をインストールします。
% npm install electron
 
> electron@2.0.4 postinstall /Users/user/node_modules/electron
> node install.js
 
Downloading SHASUMS256.txt
[============================================>] 100.0% of 5.33 kB (5.33 kB/s)
npm WARN saveError ENOENT: no such file or directory, open '/Users/user/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '/Users/user/package.json'
npm WARN user No description
npm WARN user No repository field.
npm WARN user No README data
npm WARN user No license field.
 
+ electron@2.0.4
added 148 packages from 123 contributors and audited 217 packages in 45.28s
found 0 vulnerabilities
  • which electron コマンドを実行して、以下のように表示されれば、Electron のインストールは完了しています。
% which electron
/usr/local/bin/electron

% electron -v
v1.4.13
メッセージ:
O B F᠎ Y R