心血来潮想做一个PC端应用,就来学学Electron,以下为学习Electron时的踩坑记录。
安装
在国内安装electron
的时候,可能会因为网络原因遇到卡在Building fresh packages...
(yarn)或者是卡在node install.js
(npm)这一步上。
在项目的根目录下创建.yarnrc
或.npmrc
然后输入如下内容更改各依赖的源,即可解决该问题。
registry "https://registry.npm.taobao.org"
sass_binary_site "https://npm.taobao.org/mirrors/node-sass/"
phantomjs_cdnurl "http://cnpmjs.org/downloads"
electron_mirror "https://npm.taobao.org/mirrors/electron/"
sqlite3_binary_host_mirror "https://foxgis.oss-cn-shanghai.aliyuncs.com/"
profiler_binary_host_mirror "https://npm.taobao.org/mirrors/node-inspector/"
chromedriver_cdnurl "https://cdn.npm.taobao.org/dist/chromedriver"
C++包rebuild
使用electron就避不开要使用一些第三方的C++包,使用这些包的时候需要根据node和electr