やってみる

アウトプットすべく己を導くためのブログ。その試行錯誤すらたれ流す。

Electronをインストールする

 ハマったけどできた。

成果物

前提

手順

インストール

sudo npm install electron -g

log

/usr/local/bin/electron -> /usr/local/lib/node_modules/electron/cli.js

> core-js@3.8.2 postinstall /usr/local/lib/node_modules/electron/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"

Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!

The project needs your help! Please consider supporting of core-js on Open Collective or Patreon: 
> https://opencollective.com/core-js 
> https://www.patreon.com/zloirock 

Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)


> electron@11.2.0 postinstall /usr/local/lib/node_modules/electron
> node install.js

Error: EACCES: permission denied, mkdtemp '/usr/local/lib/node_modules/electron/electron-download-daxe8n'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! electron@11.2.0 postinstall: `node install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the electron@11.2.0 postinstall 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!     /root/.npm/_logs/2021-01-15T07_20_33_256Z-debug.log

sudo npm i electron -g

 なお、sudoがないとパーミッションエラーになるっぽい。

npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules

 だから以下のようなコマンドもダメだった。

npm i electron -g
npm install electron -g

 グローバル-gをやめてみる。成功した。カレントディレクトリにインストールされた。数分かかった。

npm i electron
> core-js@3.8.2 postinstall /tmp/work/JS.FileSystemAccessAPI.20210114193647/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"

Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!

The project needs your help! Please consider supporting of core-js on Open Collective or Patreon: 
> https://opencollective.com/core-js 
> https://www.patreon.com/zloirock 

Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)


> electron@11.2.0 postinstall /tmp/work/JS.FileSystemAccessAPI.20210114193647/node_modules/electron
> node install.js

Downloading electron-v11.2.0-linux-armv7l.zip: [===============================================================] 100% ETA: 0.0 seconds 
npm WARN saveError ENOENT: no such file or directory, open '/tmp/work/JS.FileSystemAccessAPI.20210114193647/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 '/tmp/work/JS.FileSystemAccessAPI.20210114193647/package.json'
npm WARN JS.FileSystemAccessAPI.20210114193647 No description
npm WARN JS.FileSystemAccessAPI.20210114193647 No repository field.
npm WARN JS.FileSystemAccessAPI.20210114193647 No README data
npm WARN JS.FileSystemAccessAPI.20210114193647 No license field.

+ electron@11.2.0
added 89 packages from 99 contributors and audited 89 packages in 298.128s

6 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

 公式サイトは以下だった。早く言ってよ。

npm install electron --save-dev

 バージョン確認。

npx electron -v
v11.2.0

更新

 最新の安定版にアップデートする。

npm install --save-dev electron@latest

実行

npx electron

f:id:ytyaru:20210115170036p:plain

Hello World

 プロジェクトを作成する。

npx create-electron-app my-electron-app

 実行する。

cd my-electron-app
npm start

 できた。

f:id:ytyaru:20210115170048p:plain

対象環境

$ uname -a
Linux raspberrypi 5.4.83-v7l+ #1379 SMP Mon Dec 14 13:11:54 GMT 2020 armv7l GNU/Linux