NPM 相关命令,报错 node-gyp... 的解决方法_node-gyp-build-程序员宅基地

技术标签: node.js  前端  Node.js  npm  

NPM 相关命令,报错 node-gyp… 的解决方法

'node-gyp-build' is not recognized as an internal or external command, operable program or batch file.
npm ERR! gyp verb `which` failed Error: not found: python2

相关的异常信息

> node-gyp-build


                    errorOut='node-gyp-build' is not recognized as an internal or external command,
    operable program or batch file.
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! [email protected] install: `node-gyp-build`
    npm ERR! Exit status 1
    npm ERR!
    npm ERR! Failed at the [email protected] install script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

    npm ERR! A complete log of this run can be found in:
    npm ERR!     D:\app\nodejs\npm-cache\_logs\2022-06-10T00_53_04_766Z-debug.log

                    command='D:\app\nodejs\node.exe' 'D:\app\nvm\v14.7.0\node_modules\npm\bin\npm-cli.js' rebuild [email protected]
                    workingDir=
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] pack:dir: `node build-config/pack.js && electron-builder --dir`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] pack:dir script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     D:\app\nodejs\npm-cache\_logs\2022-06-10T00_53_04_842Z-debug.log

通用的解决方案

1. 在线安装,适合拥有纯净 Windows 开发环境的用户(没有安装过 Python, Visual Studio 等…)

# 全局设置淘宝镜像(配置过的老鸟可忽略此步骤)
$ npm config set registry https://registry.npm.taobao.org
# 单次使用淘宝镜像(会使用的老鸟可忽略此步骤)
$ npm install -g node-gyp --registry=https://registry.npm.taobao.org
$ npm install -g --production windows-build-tools --registry=https://registry.npm.taobao.org

2. 手动安装,针对拥有非纯净 Windows 开发环境的老鸟(安装过 Python, Visual Studio 等…)

重点注意: 等到 Starting installation... 命令字样出现后,立马 Ctrl + C 终止后面的安装过程
!!! 因为我们必须自定义安装这两个新环境,才能不影响我们系统中已安装的 python 和 vs 等环境。

  • 巧妙获取 python2 和 msvs_version 相关版本的安装包
$ npm install --global --production windows-build-tools
npm WARN deprecated [email protected]: Node.js now includes build tools for Windows. You probably no longer need this tool. See https://github.com/felixrieseberg/windows-build-tools for details.
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.

> [email protected] postinstall D:\app\nodejs\node_global\node_modules\windows-build-tools
> node ./dist/index.js



Downloading python-2.7.15.amd64.msi
[============================================>] 100.0% of 20.2 MB (9 MB/s)
Downloaded python-2.7.15.amd64.msi. Saved to C:\Users\cpw\.windows-build-tools\python-2.7.15.amd64.msi.
Downloading vs_BuildTools.exe
[============================================>] 100.0% of 1.12 MB (1.12 MB/s)
Downloaded vs_BuildTools.exe. Saved to C:\Users\cpw\.windows-build-tools\vs_BuildTools.exe.

Starting installation...
Launched installers, now waiting for them to finish.
This will likely take some time - please be patient!

Status from the installers:
---------- Visual Studio Build Tools ----------
Still waiting for installer log file...
------------------- Python --------------------
Still waiting for installer log file...^C
  • 手动安装 python2 和 msvs_version 到自定义目录
# 静默安装 python2 到指定的目录
Microsoft Windows [版本 10.0.19044.1706]
(c) Microsoft Corporation。保留所有权利。

C:\Users\cpw\.windows-build-tools>msiexec /a C:\Users\cpw\.windows-build-tools\python-2.7.15.amd64.msi /quiet TargetDir="C:/app/pvm/v2.7.15"
# 静默安装 vs_BuildTools 到默认的目录
C:\Users\cpw\.windows-build-tools>vs_BuildTools.exe /quiet PrependPath=0 Include_launcher=0 Include_test=0 Include_tcltk=0 Shortcuts=0

  • 全局设置 python2 和 msvs_version 环境变量
# 全局设置 python2 环境变量
$ npm config set python "C:\app\pvm\v2.7.15\python.exe"
# 全局设置 buildTools 环境变量
$ npm config set msvs_version "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools"

查看 NPM 全局配置

$ npm config list -g
; cli configs
global = true
metrics-registry = "https://registry.npm.taobao.org/"
scope = ""
user-agent = "npm/6.14.13 node/v14.17.0 win32 x64"

; userconfig C:\Users\cpw\.npmrc
CHROMEDRIVER_CDNURL = "https://npm.taobao.org/mirrors/chromedriver"
ELECTRON_BUILDER_BINARIES_MIRROR = "https://npm.taobao.org/mirrors/electron-builder-binaries/"
ELECTRON_MIRROR = "https://npm.taobao.org/mirrors/electron/"
NVM_NODEJS_ORG_MIRROR = "https://npm.taobao.org/mirrors/node"
OPERADRIVER = "https://npm.taobao.org/mirrors/operadriver"
PYTHON_MIRROR = "https://npm.taobao.org/mirrors/python"
cache = "D:\\app\\nodejs\\npm-cache"
chromedriver_cdnurl = "https://npm.taobao.org/mirrors/chromedriver"
electron-builder-binaries_mirror = "https://npm.taobao.org/mirrors/electron-builder-binaries/"
electron_mirror = "https://npm.taobao.org/mirrors/electron/"
msvs_version = "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools"
node_sqlite3_binary_host_mirror = "http://npm.taobao.org/mirrors"
phantomjs_cdnurl = "https://npm.taobao.org/mirrors/phantomjs"
prefix = "D:\\app\\nodejs\\node_global"
python = "‪D:\\app\\pvm\\v2.7.15\\python.exe"
registry = "https://registry.npm.taobao.org/"
sass_binary_site = "https://npm.taobao.org/mirrors/node-sass/"
strict-ssl = false

; node bin location = D:\app\nodejs\node.exe
; cwd = D:\code\NodejsProjects\lx-music-desktop
; HOME = C:\Users\cpw
; "npm config ls -l" to show all defaults.


版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/sinat_36112136/article/details/125216695

智能推荐

ARP实现简单断网攻击_arp断网攻击演示-程序员宅基地

文章浏览阅读2.6k次。ARP实现简单断网攻击环境准备:1:一台kali2:一台win7虚拟机在讲如何进行攻击前,我先来简单介绍下arp(已经有很多大佬的博客把原理写的很清楚了,大家如有需要可以自己详细去看下,这里附上大佬博客:arp攻击arp:地址解析协议,目的是实现IP地址与MAC地址的转换,而MAC地址是真正计算机唯一标识arp攻击则是利用这一特点来进行攻击的,假设B向A发送数据,C就伪造成A,这就造成了劫持数据,造成断网,甚至监听原理大概就是这样了,我就细细讲下攻击过程(原理主要是自己也不太会写,写出来全是口_arp断网攻击演示

Android开发中的错误及解决办法总结_the 'kotlin-android-extensions' gradle plugin is d-程序员宅基地

文章浏览阅读7k次。Android开发中的错误及解决办法总结 _the 'kotlin-android-extensions' gradle plugin is deprecated. please use this

nacos-ErrMsg:failed to req API:/api//nacos/v1/ns/instance after all servers([127.0.0.1:8848]) tried_failed to req api:/nacos/v1/ns/instance after all -程序员宅基地

文章浏览阅读6.6k次。服务注册到nacos报错:ErrMsg:failed to req API:/api//nacos/v1/ns/instance after all servers([127.0.0.1:8848]) tried: server is DOWN now, please try again later!解决办法:_failed to req api:/nacos/v1/ns/instance after all servers([127.0.0.1:8848])

sparkSql catalyst优化器-程序员宅基地

文章浏览阅读300次。2019独角兽企业重金招聘Python工程师标准>>> ..._sparksql 优化器 估算结果集

习题2-3 求平方与倒数序列的部分和 (15分)-程序员宅基地

文章浏览阅读128次。本题要求对两个正整数m和n(m≤n)编写程序,计算序列和m​2​​ +1/m+(m+1)​2​​ +1/(m+1)+⋯+n​2​​ +1/n。输入格式:输入在一行中给出两个正整数m和n(m≤n),其间以空格分开。输出格式:在一行中按照“sum = S”的格式输出部分和的值S,精确到小数点后六位。题目保证计算结果不超过双精度范围。输入样例:5 10输出样例:sum = 355.845635#include<stdio.h>int main(){ int m,n;_习题2-3 求平方与倒数序列的部分和 (15分)

Loadrunner的IP欺骗(含图)_loadrunner作假图-程序员宅基地

文章浏览阅读1k次。转载出处:http://www.51testing.com/?41972使用loadrunner进行IP欺骗首先要注意以下两点:1、 本地的IP设置不能为“自动获取”,必须指定一个静态IP如果本地是动态获取IP,在运行IP Wizard时会弹出提示:The IP_loadrunner作假图

随便推点

【C++】STL之unoerdered_map、unordered_set类源码剖析_unodermap 源码-程序员宅基地

文章浏览阅读2.2k次。C++通过哈希表实现对unordered_map、unordered_set的封装_unodermap 源码

WordPress 阿里云虚拟主机发送邮件配置_阿里云如何设置虚拟邮箱-程序员宅基地

文章浏览阅读1.7k次。本次配置是在wordpress4.9.4上测试第一步:首先需要进入阿里云虚拟主机控制台修改php.ini配置文件,启用一个函数PHP函数fsockopen设置:开启第二步 修改配置文件:/wp-include/class-smtp.php找到以下代码:$this-&gt;smtp_conn = @stream_socket_client($host . “:” . $port,$errno,$er..._阿里云如何设置虚拟邮箱

esp32 io速度_Adafruit HUZZAH32-ESP32Feather的说明-程序员宅基地

文章浏览阅读661次。概述是的,是您一直在等待的羽毛!HUZZAH32是我们基于ESP32的Feather,使用官方WROOM32模块制成。我们打包了您喜欢的所有有关Feathers的东西:内置USB到串行转换器,自动引导程序重置,锂离子/聚合物充电器以及所有带出的GPIO,因此您可以将其与我们的FeatherWings一起使用。位于该Feather末尾的模块包含一个双核ESP32芯片,4MB的SPIFlash,调谐的..._.pio/libdeps/featheresp32/adafruit busio/adafruit_spidevice.h:9:10: fatal er

电商购物核心功能测试点_中慧 电子商城功能测试-程序员宅基地

文章浏览阅读1.4w次,点赞28次,收藏229次。这份是根据电商中所涉及的业务点整理出的核心功能测试点,更多的偏向于功能性的测试。其后所涉及到的性能测试、压力测试、集成测试等,会在进一步分析,作为一名产品经理应该了解到这部分知识点。..._中慧 电子商城功能测试

语义网络,语义网,链接数据和知识图谱_语义网 图数据库-程序员宅基地

文章浏览阅读7.1k次。前一篇文章“为什么需要知识图谱?什么是知识图谱?——KG的前世今生”提及了和知识图谱相关的一些早期概念。为了让读者能够更好地区分这些概念,以及更好地在整体上把握知识谱图发展过程,本文将对这些概念作一个更为详细的介绍。一、语义网络(Semantic Network)对于初学者来讲,这个概念很容易和..._语义网 图数据库

scala 之 map 操作史上最全_scala map添加元素-程序员宅基地

文章浏览阅读4.6w次,点赞11次,收藏75次。Map(映射)是一种可迭代的键值对(key/value)结构。所有的值都可以通过键来获取。Map 中的键都是唯一的。Map 也叫哈希表(Hash tables)。Map 有两种类型,可变与不可变,区别在于可变对象可以修改它,而不可变对象不可以。默认情况下 Scala 使用不可变 Map。如果你需要使用可变集合,你需要显式的引入 import scala.collection.mutabl..._scala map添加元素

推荐文章

热门文章

相关标签