通过 npm 安装 electron 时出错

通过 npm 安装 electron 时出错

我尝试使用 NPM 安装 Electron,结果出现了以下信息:

adi@LMToshi2 ~ $ npm install electron --save-dev --save-exact
npm ERR! Linux 4.8.0-53-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "electron" "-
-save-dev" "--save-exact"
npm ERR! node v4.2.6
npm ERR! npm  v3.5.2
npm ERR! code ECONNRESET
npm ERR! errno ECONNRESET
npm ERR! syscall read

npm ERR! network read ECONNRESET
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network 
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.  See: 'npm help config'
npm ERR! Linux 4.8.0-53-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "electron" "--save-dev" "--save-exact"
npm ERR! node v4.2.6
npm ERR! npm  v3.5.2
npm ERR! code ECONNRESET
npm ERR! errno ECONNRESET
npm ERR! syscall read

npm ERR! network read ECONNRESET
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network 
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.  See: 'npm help config'
npm ERR! Linux 4.8.0-53-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "electron" "--save-dev" "--save-exact"
npm ERR! node v4.2.6
npm ERR! npm  v3.5.2
npm ERR! code ECONNRESET
npm ERR! errno ECONNRESET
npm ERR! syscall read

npm ERR! network read ECONNRESET
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network 
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.  See: 'npm help config'
WARN engine [email protected]: wanted: {"node":">=4.5.0"} (current: {"node":"4.2.6","npm":"3.5.2"})

顺便说一句:我是不是在代理中。

答案1

确保安装了最新版本的 Node!sudo apt install node不安装最新版本,看起来您使用的是 4.2.6 版,而 electron 需要更新或等于 4.5.0 版的版本。尝试使用此方法安装节点:

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -

然后输入:

sudo apt-get install -y nodejs

(来源:https://nodejs.org/en/download/package-manager/

相关内容