electron在龙芯平台上本地安装使用(一)

本文介绍了在Loongnix系统中安装Electron 4.1.3和6.1.7的详细过程,包括从特定网址下载软件包、文件校验值的生成、预安装脚本的执行等步骤。同时,针对Electron 10.1.0,由于其安装方式改变,文中提供了使用环境变量进行本地缓存安装的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

注意
本文所述的安装方法对electron的4.1.3,6.1.7有效,对10.1.0无效,10.1.0临时安装方法参见文章底部。

  1. 安装electron前的准备

从http://www.loongnix.org/index.php/Electron下载所需软件包,

a)将tar包解开,重新压缩成zip包

tar xzf electron_v4.1.3.tar.gz
cd electron_v4.1.3
zip -r electron-v4.1.3-linux-mips64el.zip ./* 
mv electron-v4.1.3-linux-mips64el.zip ../

b)执行如下命令,生成文件校验值

sha256sum electron-v4.1.3-linux-mips64el.zip > SHASUMS256.txt-4.1.3

执行完成后打开SHASUMS256.txt-4.1.3,如下:

e461f4158e68c41ed824ba2f59a36079e6ae596d1ad7a8a72d1722b78d251e81  electron-v4.1.3-linux-mips64el.zip

改为如下:

e461f4158e68c41ed824ba2f59a36079e6ae596d1ad7a8a72d1722b78d251e81 *electron-v4.1.3-linux-mips64el.zip

注意:
没更改之前e461f4158e68c41ed824ba2f59a36079e6ae596d1ad7a8a72d1722b78d251e81和electron-v4.1.3-linux-mips64el.zip有两个空格,改完后有一个空格,并有一个*号做分隔符。

c)执行如下脚本,将electron-v4.1.3-linux-mips64el.zip和SHASUMS256.txt-4.1.3放到~/.cache/electron/下

./preinstall.sh

preinstall.sh如下:

#!/usr/bin/env bash
 
 # 在安装electron前的环境设置
 
 electron_path="$HOME/.cache/electron"
 if [ ! -d ${electron_path} ]; then
     mkdir -p ${electron_path}
 fi
 
 electron="electron-v4.1.3-linux-mips64el.zip"
 shasums="SHASUMS256.txt-4.1.3"
 
 if [ -f ${electron} -a -f  ${shasums} ];then
     cp ${electron} ${shasums} ${electron_path}
 else
     echo "${electron} and ${shasums} doesn't exists"
     exit 1
 fi
 
 echo "preinstall done"

  1. 本地安装electron

如果,当前网络不能有效的安装electron,建议将npm的镜像源地址修改为国内源

npm config set registry https://registry.npm.taobao.org
  • 本地项目安装electron
git clone https://github.com/electron/electron-quick-start.git
cd electron-quick-start/
git checkout remotes/origin/4-x-y
npm install electron@4.1.3

测试electron是否正确安装:

cd electron-quick-start/
npm start

执行之后,会在本地弹出页面窗口,并显示当前的electron版本。

表明electron已经正确安装。

  • 全局安装electron
npm install electron@4.1.3 -g

如果提示有诸如accesspermission的权限问题,请添加--unsafe-perm=true参数

如下:

npm install electron@4.1.3 -g --unsafe-perm=true

10.1.0安装

由于4和6版本使用的下载模块是electron-download,支持本地cache和本地mirror进行安装,但是到了10.1.0,使用的是electron/get模块安装,不在支持本地cache了。但是可以通过设置如下参数解决10.1.0的安装
Using environment variables for mirror

options                                                                                                                                         
 Mirror options can also be specified via the following environment variables:                                                                                                                
 * `ELECTRON_CUSTOM_DIR` - Specifies the custom directory to download from.                                                                                                                   
 * `ELECTRON_CUSTOM_FILENAME` - Specifies the custom file name to download.                                                                                                                   
 * `ELECTRON_MIRROR` - Specifies the URL of the server to download from if the version is not a nightly version.                                                                              
 * `ELECTRON_NIGHTLY_MIRROR` - Specifies the URL of the server to download from if the version is a nightly version.   

问题

  1. 运行electron出现问题

把缓存重新删除,卸载electron。到解压出来的目录中执行预处理脚本,然后重新安装electron

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值