npm 打包 electron app 报错问题

在进行desktop打包过程中,遇到如下报错:

 

看到 stackoverflow 上面 http://stackoverflow.com/questions/35040729/running-npm-install-g-yo-command-gives-npm-err-windows-nt-6-1-7601/35043377#35043377 有这个解决办法:

This is how I solved the issue on Windows 8.1

  • Go to your nodejs install (usually C:\Program Files\nodejs)
  • Right click node_modules folder and go to properties
  • Click the Security tab and advanced
  • At the top you will see "Owner: SYSTEM". Click change.
  • Enter the user you want permissions for and click ok
  • Check the box at the bottom of the advanced settings "Replace all child object permission entries with inheritable permission entries from this object" and click ok
  • Do whatever npm install/update you need

(另一个关于electron的问题:http://www.cnblogs.com/haochuang/p/5688093.html)

用该办法尝试,但未解决,再次尝试其他办法;

 

本文转自 念槐聚 博客园博客,原文链接:http://www.cnblogs.com/haochuang/p/5754120.html,如需转载请自行联系原作者

### 解决 `npm install electron` 报错的方法 当遇到 `npm install electron` 出现错误的情况时,可以通过一系列配置来解决问题。具体措施如下: 对于 Electron 版本问题,在项目根目录创建 `.npmrc` 文件并设定特定参数有助于解决兼容性和依赖项构建失败的问题[^1]。 ```bash # 创建 .npmrc 文件并写入以下内容 echo "target=2.0.18" >> .npmrc echo "arch=x64" >> .npmrc echo "disturl=https://npm.taobao.org/mirrors/atom/" >> .npmrc echo "runtime=electron" >> .npmrc ``` 如果直接通过 npm 安装出现问题,则考虑清除本地缓存,并尝试使用 cnpm 进行安装以绕过可能存在的网络连接障碍[^2]。 ```bash # 清理 npm 缓存强制清理模式 npm cache clean --force # 使用淘宝镜像下的 cnpm 工具代替默认的 npm npm install -g cnpm --registry=https://registry.npm.taobao.org # 采用 cnpm 来安装 electron 并保存到 devDependencies 中 cnpm i electron --save-dev ``` 针对安装过程中的长时间停滞现象,除了上述方法外还需要进一步调整 npm 配置选项以便加速资源获取效率[^3]。 ```bash # 将全局仓切换至国内镜像源提高下载速度 npm config set registry https://registry.npm.taobao.org # 显式指明 disturl 参数指向更快捷稳定的服务器位置 npm config set disturl https://npm.taobao.org/dist # 对于 electron 自身也应指定其对应的中国区代理链接 npm config set electron_mirror https://npm.taobao.org/mirrors/electron/ ``` 以上操作能够有效改善因国内外网络差异所引起的包管理工具工作异常状况,从而顺利完成 Electron 的安装流程[^4]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值