.npmrc 文件
registry=http://registry.npm.taobao.org/
msvs_version=2015
python=D:\Python38\python.exe
node_gyp=D:\nvm\nvm\v14.16.1\node_modules\node-gyp\lib\node-gyp.js
npm配置安装最新淘宝镜像,旧镜像会error
注意 ,这个镜像会造成error!!: https://registry.npm.taobao.org
切换npm淘宝镜像
1、 npm config set registry https://registry.npmmirror.com/,切换国内镜像,使用淘宝镜像
2、npm config get registry,查看当前镜像使用的地址,返回成功,则代表设置成功registry=https://registry.npmmirror.com/ ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/ electron-builder-binaries_mirror=https://registry.npmmirror.com/-/binary/electron-builder-binaries/
electron:build因为网络环境问题winCodeSign nsis和nsis-resources无法下载
解决思路: 自己手动去下载下来放在本地缓存中
下载地址 Index of electron-builder-binaries-local
nsis打包的路径包含中文,导致一些文件路径乱码 无法识别 出现的各种 could not find: 问题
1.路径中出现的中文全部改掉,挪动文件夹,更改电windows账户名之类的原始方法
2.想办法让打包插件支持文中,修改依赖文件
在node_module/app-builder-lib/out/targets/nsis/NsisTarget.js文件里面 找到executeMakensis方法。添加支持中文编码的代码
async executeMakensis(defines, commands, script) {
const args = this.options.warningsAsErrors === false ? [] : ["-WX"];
// 只需要加下面这一行即可
args.push("-INPUTCHARSET", "UTF8");
for (const name of Object.keys(defines)) {
const value = defines[name];
if (value == null) {
args.push(`-D${name}`);
}
else {
args.push(`-D${name}=${value}`);
}
}
for (const name of Object.keys(commands)) {
const value = commands[name];
if (Array.isArray(value)) {
for (const c of value) {
args.push(`-X${name} ${c}`);
}
}
else {
args.push(`-X${name} ${value}`);
}
}
args.push("-");
if (this.packager.debugLogger.isEnabled) {
this.packager.debugLogger.add("nsis.script", script);
}
const nsisPath = await nsisUtil_1.NSIS_PATH();
const command = path.join(nsisPath, process.platform === "darwin" ? "mac" : process.platform === "win32" ? "Bin" : "linux", process.platform === "win32" ? "makensis.exe" : "makensis");
// if (process.platform === "win32") {
// fix for an issue caused by virus scanners, locking the file during write
// https://github.com/electron-userland/electron-builder/issues/5005
await ensureNotBusy(commands["OutFile"].replace(/"/g, ""));
// }
await builder_util_1.spawnAndWrite(command, args, script, {
// we use NSIS_CONFIG_CONST_DATA_PATH=no to build makensis on Linux, but in any case it doesn't use stubs as MacOS/Windows version, so, we explicitly set NSISDIR
env: { ...process.env, NSISDIR: nsisPath },
cwd: nsisUtil_1.nsisTemplatesDir,
});
}