Refusing to delete /usr/local/bin/electron: ../lib/node_modules/electron-prebuilt/cli.js symlink target is not controlled by npm /usr/local/bin

「Refusing to delete /usr/local/bin/electron: ../lib/node_modules/electron-prebuilt/cli.js symlink target is not controlled by npm /usr/local/bin」のアイキャッチ画像

electronを試してみようと思いこちらのコードを走らせたらタイトルのエラーが発生しました

$sudo npm install electron -g

ちなみにこちらを試したところダメだったので、

$ sudo npm install electron -g --verbose --unsafe-perm=true
# エラーの原因を消してみる
$ sudo rm /usr/local/bin/electron 
$ sudo rm -rf ~/.electron/ 

# もう一度実行
$ sudo npm install -g electron-prebuilt

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! electron-prebuilt@1.4.13 postinstall: `node install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the electron-prebuilt@1.4.13 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:

まだエラーが出るので、調べてからもう一度一からやってみます

$ sudo rm /usr/local/bin/electron 
$ sudo rm -rf ~/.electron/ 
$ npm cache verify
$ sudo npm install electron -g --verbose --unsafe-perm=true

# 省略
npm timing stage:runTopLevelLifecycles Completed in 41184ms
+ electron@8.1.1
added 86 packages from 96 contributors in 41.186s
npm verb exit [ 0, true ]
npm timing npm Completed in 41638ms
npm info ok 

これで入りました

目次
  1. 参考記事

参考記事

npm install electron failing at the electron@1.4.15 postinstall script ‘node install.js’ #233
Error: Refusing to delete: /usr/local/bin/npm #3794
WSF(Ubuntu)でElectronをインストールする際につまったときのメモ
error electron-prebuilt@1.4.2 postinstall: `node install.js` #197