LoginSignup
24
21

More than 5 years have passed since last update.

electronのインストールでコケた時の解決方法 on OS X

Last updated at Posted at 2016-02-24

ちょっとelectronをさわってみようと思ってインストールコマンドを叩いたら、
エラーでコケてハマったので、その時の対処法をメモ。

ちなみにインストールがコケたのは、Mac OSX El Capitanです。

症状

sudo npm install -g electron-prebuilt

を走らせると、以下のようなエラーに遭遇

> electron-prebuilt@0.36.8 postinstall /usr/local/lib/node_modules/electron-prebuilt
> node install.js

Downloading electron-v0.36.8-darwin-x64.zip
[============================================>] 100.0% of 40.52 MB (281.37 kB/s)
/usr/local/lib/node_modules/electron-prebuilt/install.js:22
  throw err
  ^

Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/electron-prebuilt/electron-tmp-download-15324-1456330921961/electron-v0.36.8-darwin-x64.zip' -> '/Users/******/.electron/electron-v0.36.8-darwin-x64.zip'
    at Error (native)
npm ERR! Darwin 15.3.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "electron-prebuilt@0.36.8"
npm ERR! node v5.7.0
npm ERR! npm  v3.7.3
npm ERR! code ELIFECYCLE

npm ERR! electron-prebuilt@0.36.8 postinstall: `node install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the electron-prebuilt@0.36.8 postinstall script 'node install.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the electron-prebuilt package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node install.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs electron-prebuilt
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls electron-prebuilt
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/******/npm-debug.log

解決方法

nodesとnamのバージョンが最新のものになるようにしつつ、インストールし直しをすれば良いらしい。
ということなので、nodejsのバージョンを最新のものにする。

管理が楽になるのでnを入れて、nで作業することにする。

npm install -g n
n latest

npmのアップデートは、npm自信で出来るので素直に以下の通り

npm update -g npm

んでもって、悪さしてそうな子を消して、npmのキャッシュクリア

rm -rf ~/.electron/
npm cache clear

最後に、npmのページにある通りにelectronのインストールコマンドを打ち直す

sudo npm install -g electron-prebuilt

これで私の環境ではうまくインストールすることができました!

24
21
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
24
21