ElectronJs:无法安装 "install.js:22 throw err"

ElectronJs: Not able to install "install.js:22 throw err"

我从 Electron js 开始,我偶然发现了安装 Electron 的第一步。

我是运行下面提供的安装electron的命令 source

npm install electron-prebuilt --save-dev

命令结果如下

C:\Users\vikas\Desktop\electron apps\example>npm install electron-prebuilt --sa
ve-dev

electron-prebuilt@0.37.8 postinstall C:\Users\vikas\Desktop\electron apps\exa
mple\node_modules\electron-prebuilt
node install.js
C:\Users\vikas\Desktop\electron apps\example\node_modules\electron-prebuilt\ins
tall.js:22
throw err
^

Error: end of central directory record signature not found
at C:\Users\vikas\Desktop\electron apps\example\node_modules\yauzl\index.js
:167:14
at C:\Users\vikas\Desktop\electron apps\example\node_modules\yauzl\index.js
:473:5
at C:\Users\vikas\Desktop\electron apps\example\node_modules\fd-slicer\inde
x.js:32:7
at FSReqWrap.wrapper as oncomplete
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\vikas\Desktop
\electron apps\example\package.json'
npm WARN example No description
npm WARN example No repository field.
npm WARN example No README data
npm WARN example No license field.
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Users\vikas\AppData\
\Roaming\npm\node_modules\npm\bin\npm-cli.js" "install" "electron-prebuilt"
"--save-dev"
npm ERR! node v4.4.3
npm ERR! npm v3.8.9
npm ERR! code ELIFECYCLE

npm ERR! electron-prebuilt@0.37.8 postinstall: node install.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the electron-prebuilt@0.37.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 pac
kage,
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! C:\Users\vikas\Desktop\electron apps\example\npm-debug.log

Windows 8.1

NPM 版本 3.8.9

C:\Users\vikas\Desktop\electron apps\example\package.json存在吗?如果没有尝试 运行ning npm init 创建它,然后 运行 npm install electron-prebuilt --save-dev 再次创建它。

这是一个错误,github 上提供了解决方法:Source

解决方法如下:

rm -rf ~/.electron/
rm -rf ~/.atom/
npm cache clear
npm install

我遇到了类似的问题。但是以管理员身份打开命令提示符 (Windows) 并重新安装 electron 解决了这个问题。