首页 > 其他分享 >解决npm安装electron失败的问题

解决npm安装electron失败的问题

时间:2024-07-25 17:29:05浏览次数:16  
标签:npm node verbose modules electron error 安装

1.问题描述

使用npm创建项目后,添加electron依赖
npm install electron --save-dev
一直报错,部分报错日志如下
484 silly audit error [object Object]
485 silly audit report null
486 info run [email protected] postinstall { code: 1, signal: null }
487 verbose stack Error: command failed
487 verbose stack     at promiseSpawn (C:\Users\Administrator\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\promise-spawn\lib\index.js:22:22)
487 verbose stack     at spawnWithShell (C:\Users\Administrator\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\promise-spawn\lib\index.js:124:10)
487 verbose stack     at promiseSpawn (C:\Users\Administrator\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\promise-spawn\lib\index.js:12:12)
487 verbose stack     at runScriptPkg (C:\Users\Administrator\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\run-script\lib\run-script-pkg.js:77:13)
487 verbose stack     at runScript (C:\Users\Administrator\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\run-script\lib\run-script.js:9:12)
487 verbose stack     at C:\Users\Administrator\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\rebuild.js:329:17
487 verbose stack     at run (C:\Users\Administrator\AppData\Roaming\npm\node_modules\npm\node_modules\promise-call-limit\dist\commonjs\index.js:67:22)
487 verbose stack     at C:\Users\Administrator\AppData\Roaming\npm\node_modules\npm\node_modules\promise-call-limit\dist\commonjs\index.js:84:9
487 verbose stack     at new Promise (<anonymous>)
487 verbose stack     at callLimit (C:\Users\Administrator\AppData\Roaming\npm\node_modules\npm\node_modules\promise-call-limit\dist\commonjs\index.js:35:69)
488 verbose pkgid [email protected]
489 error code 1
490 error path C:\Workspace\VsCode\electron\papercup\node_modules\electron
491 error command failed
492 error command C:\WINDOWS\system32\cmd.exe /d /s /c node install.js
493 error RequestError: connect ETIMEDOUT 140.82.121.4:443
493 error     at ClientRequest.<anonymous> (C:\Workspace\VsCode\electron\papercup\node_modules\got\dist\source\core\index.js:970:111)
493 error     at Object.onceWrapper (node:events:634:26)
493 error     at ClientRequest.emit (node:events:531:35)
493 error     at origin.emit (C:\Workspace\VsCode\electron\papercup\node_modules\@szmarczak\http-timer\dist\source\index.js:43:20)
493 error     at TLSSocket.socketErrorListener (node:_http_client:500:9)
493 error     at TLSSocket.emit (node:events:519:28)
493 error     at emitErrorNT (node:internal/streams/destroy:169:8)
493 error     at emitErrorCloseNT (node:internal/streams/destroy:128:3)
493 error     at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
493 error     at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1606:16)
494 silly unfinished npm timer reify 1721836281026
495 silly unfinished npm timer reify:build 1721836281989
496 silly unfinished npm timer build 1721836281989
497 silly unfinished npm timer build:deps 1721836281990
498 silly unfinished npm timer build:run:postinstall 1721836282003
499 silly unfinished npm timer build:run:postinstall:node_modules/electron 1721836282003
500 verbose cwd C:\Workspace\VsCode\electron\papercup
501 verbose os Windows_NT 10.0.22631
502 verbose node v20.15.1
503 verbose npm  v10.8.2
504 verbose exit 1
505 verbose code 1
506 error A complete log of this run can be found in: C:\Users\Administrator\AppData\Local\npm-cache\_logs\2024-07-24T15_51_20_629Z-debug-0.log

2.问题分析

根据日志以及网络查找到的信息,分析原因为安装electron时,npm会下载一个非常大的二进制文件,再加上网络不好最终导致安装失败

3.开始解决

尝试过的方法包括不限于
  1.  更换npm镜像源
    npm config set registry="https://registry.npmmirror.com"

     

  2.  设置环境变量
    ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/</code>

     

  3.  使用cnpm
    npm install -g cnpm --registry=https://registry.npmmirror.com
    cnpm install electron --save-dev

    最终使用第三种方法成功解决问题

标签:npm,node,verbose,modules,electron,error,安装
From: https://www.cnblogs.com/zhaomifan/p/18323748

相关文章

  • 最新nacos下载安装,版本号2.4.0,nacos持久化存储到本地mysql中,nacos配置登录账户密码
    官网:https://nacos.io/zh-cn/docs/quickstart/quick-start1.下载地址:https://github.com/alibaba/nacos/releases网络不好,很难下载。直接使用git克隆,然后自己编译,这是最快的了。克隆:gitclonehttps://github.com/alibaba/nacos.git然后到根目录中(我的:E:\Demos\nacos),执行cmd命令:mv......
  • 虚拟机环境下Rocky 9.4安装Mysql8并配置Dbeaver客户端
    环境:服务器操作系统:Rocky9.4数据库:mysql8.0.38客户端操作系统:windows10Dbeaver版本:24.1.3Rocky9.4安装镜像下载地址:https://mirrors.aliyun.com/rockylinux/9.4/isos/x86_64/Rocky-9.4-x86_64-dvd.isoDbeaver安装文件下载链接:https://dbeaver.io/files/dbeaver-c......
  • docker安装HANA数据库
    对于开发和测试场景,可以考虑安装hanaexpress,仓库地址为https://hub.docker.com/r/saplabs/hanaexpress安装步骤如下:1.修改/etc/sysctl.conf文件vim/etc/sysctl.conf在末尾填入以下信息fs.file-max=20000000fs.aio-max-nr=262144vm.memory_failure_early_kill=1vm.max......
  • JDK下载与安装
    JDK下载1.JDK可以到官网下载http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html2.以安装jdk8为例,双击运行jdk-8u202-window-x64.exe,点击下一步下一步之后可以更改路径:3.一直点击下一步安装即可JDK环境变量配置1.打开控制面板->系统和......
  • 如何在Mac电脑上安装Python 2
    Python是一种高级编程语言,广泛应用于数据科学、网络开发、人工智能等领域。本文将介绍如何在Mac电脑上安装Python2,帮助初学者快速入门。一、下载Python2安装包在Python官网上下载Python2的安装包,网址为https://www.python.org/downloads/release/python-2718/ 。下载完......
  • 鸿蒙4.2安装apk应用软件
    先在电脑安装adb:https://blog.csdn.net/qq_37858386/article/details/119351940在手机上开开发者模式:点击关于手机里的harmonyOS版本号,点个四五次就弹出来了在手机上搜索usb:把usb调试打开:用数据线连接电脑,把usb配置改成以太网:进入cmd,如果没配adb全局变量,就进入adb的目录,使用a......
  • 尝试安装 dlib 出现此错误
    当我尝试pipinstalldlib时,终端会返回此信息。我试图为一个项目安装face_recognition,它要求我安装cmake,我这样做了,但是当我尝试安装dlib时,出现了这个错误CollectingdlibUsingcacheddlib-19.24.4.tar.gz(3.3MB)Installingbuilddependencies...doneG......
  • 开源照片管理神器 PhotoPrism 安装和使用教程
    如今我们每个人都积累了海量的照片和视频,做自媒体的UP主们积累的照片和视频数量可能更多。面对这么多的照片和视频,我们该如何管理呢?之前我一直用谷歌相册,因为它有很多优势,比如无限空间,支持智能整理(按时间线、地理位置、还支持人脸自动合并)。但去年Google开始对空间进行了......
  • 【新手小白的Clion的下载安装配置使用问题】
    MinGW与Clion下载安装及使用详解参考文章:MinGW与Clion下载安装及使用详解Clion官网点击下载clion+MinGW+opencv配置安装参考文章:clion+MinGW+opencv配置安装运行CLion,在Settings→Build,Execution,Deployment中找到toolchains。然后点击+号,添加MinGW的编译工......
  • python科学计算:加速库numba —— 安装和试用
    安装(anaconda环境下)condainstallnumbaDemo代码:fromnumbaimportjitfromnumpyimportarangeimportnumpyimporttime@jitdefsum2d(arr):M,N=arr.shaperesult=0.0foriinrange(M):forjinrange(N):result+=a......