npm 淘宝镜像error, electron:build打包error

.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,
        });
    }

  • 10
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值