Vue项目本地打包桌面应用exe失败--修改配置;2024npm淘宝镜像切换,旧版过期导致构建项目Build失败--切换版本

文章讲述了作者遇到的问题,即在将Vue项目打包为exe文件时,由于镜像源过期导致npmrunbuild失败。作者分享了解决方案,包括修改npm配置使用新的镜像源,并提供了常见的npm镜像网址以供参考。

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

客户相关部门,不想要线上的访问,只给本地电脑单机系统,所以本地运行前端和后端的程序,这边前端我按以往经验打包成exe文件,发现npm run build项目构建失败,卡了几天,找了很多原因才发现是镜像源过期的原因。顺便写一下项目打包桌面应用exe的步骤和方法。

打包成exe文件步骤

可参考别人的这个文章链接:

把Vue项目打包为桌面应用

一、在项目目录npm run build项目构建成功后,
二、新建一个文件夹,然后把build构建后的dist文件下的所有文件拉到新建打包文件夹下(dist目录下的,不要把整个dist拉过去),
三、然后再新建package.json,

这是原来的写法

{
  "name": "deskApp",
  "version": "1.0.0",
  "description": "",
  "main": "index.html",
  "window": {
    "title": "桌面应用",
    "icon": "",
    "width": 800,
    "height": 600,
    "toolbar": false,
    "frame": true,
    "resizable": true,
    "position": "center",
    "transparent": false,
    "show": true
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "dist": "build --tasks win-x86,win-x64 --mirror https://npm.taobao.org/mirrors/nwjs/ .",
    "start": "run --x86 --mirror https://npm.taobao.org/mirrors/nwjs/ ."
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "nwjs-builder-phoenix": "^1.15.0"
  },
  "build": {
    "nwVersion": "0.27.5"
  }
}

因为我把镜像修改了,在这里也需要修改,只需修改scripts相对应的镜像地址即可,修改后是:

{
  "name": "deskApp",
  "version": "1.0.0",
  "description": "",
  "main": "index.html",
  "window": {
    "title": "桌面应用",
    "icon": "",
    "width": 800,
    "height": 600,
    "toolbar": false,
    "frame": true,
    "resizable": true,
    "position": "center",
    "transparent": false,
    "show": true
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "dist": "build --tasks win-x86,win-x64 --mirror https://npmmirror.com/mirrors/nwjs/ .",
    "start": "run --x86 --mirror https://npmmirror.com/mirrors/nwjs/ ."
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "nwjs-builder-phoenix": "^1.15.0"
  },
  "build": {
    "nwVersion": "0.27.5"
  }
}

四、然后就可以安装完依赖后,再打包了

npm install 
npm run dist

淘宝镜像切换

然后再说下,旧版本的淘宝镜像,npm run build,和npm install,一直失败,出现npm sill idealTree buildDeps和卡在idealTree:isp-bms: sill idealTree buildDeps等等问题,原本确实不知道原因,那时候堆了几个项目,把我搞晕了,然后不管去搞别的项目了,几天后被同事告知是镜像源的问题。

我是直接输入以下这条命令就解决了,换另外的镜像

npm config set registry https://registry.npmmirror.com

以下是相关的操作命令和镜像

查看当前镜像地址:npm config get registry;

更换镜像地址(例如):npm config set registry https://registry.npm.taobao.org;(已过期)

(我原本就是这个,淘宝镜像原地址2024年1月22日已过期,所以导致这次问题的出现。)

常用的镜像网址:

npm 官方原始镜像网址是:https://registry.npmjs.org/
淘宝最新 NPM 镜像:https://registry.npmmirror.com
阿里云 NPM 镜像:https://npm.aliyun.com
华为云 NPM 镜像:https://mirrors.huaweicloud.com/repository/npm/
腾讯云 NPM 镜像:https://mirrors.cloud.tencent.com/npm/
网易 NPM 镜像:https://mirrors.163.com/npm/
清华大学开源镜像站:https://mirrors.tuna.tsinghua.edu.cn/
中科院大学开源镜像站:http://mirrors.ustc.edu.cn/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值