NPM相关命令之报错node-gyp...的解决方法

目录
  • NPM 相关命令,报错 node-gyp… 的解决方法
    • 相关的异常信息
    • 通用的解决方案
      • 1. 在线安装,适合拥有纯净 Windows 开发环境的用户(没有安装过 Python, Visual Studio 等…)
      • 2. 手动安装,针对拥有非纯净 Windows 开发环境的老鸟(安装过 Python, Visual Studio 等…)
      • 查看 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! utf-8-validate@5.0.9 install: `node-gyp-build`
    npm ERR! Exit status 1
    npm ERR!
    npm ERR! Failed at the utf-8-validate@5.0.9 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 utf-8-validate@5.0.9
                    workingDir=
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! lx-music-desktop@1.22.0-beta pack:dir: `node build-config/pack.js && electron-builder --dir`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the lx-music-desktop@1.22.0-beta 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 windows-build-tools@5.2.2: 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 request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated uuid@3.4.0: 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.

> windows-build-tools@5.2.2 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 python2 "C:\Python27\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.

总结

到此这篇关于NPM相关命令之报错node-gyp...解决的文章就介绍到这了,更多相关NPM报错node-gyp...解决内容请搜索我们以前的文章或继续浏览下面的相关文章希望大家以后多多支持我们!

(0)

相关推荐

  • node-gyp安装vuetify编译失败gyp ERR的问题及解决

    目录 问题 解决 管理安装的依赖 检查 C 盘 重新安装 总结 问题 在安装 vuetify 的时候发现了 node-gyp 编译失败的问题,报错很友好: gyp info it worked if it ends with okgyp info using node-gyp@5.1.0gyp info using node@14.8.0 | win32 | x64gyp info find Python using Python version 3.8.5 found at “D:\Progr

  • 整理 node-sass 安装失败的原因及解决办法(小结)

    npm install 时偶尔遇到报错:没有安装python或node-sass 安装失败的问题,百度之后发现是被墙了,但根据百度的方法换了淘宝镜像和用了vpn都安装失败,最后发现原来是因为没有卸载之前安装失败的包导致的.作者本人最后的解决方案是npm uninstall node-sass,然后使用VPN重新安装了一遍就成功了.不能翻墙的同学请看下文 node-sass 安装失败的原因 npm 安装 node-sass 依赖时,会从 github.com 上下载 .node 文件.由于国内网络

  • NPM相关命令之报错node-gyp...的解决方法

    目录 NPM 相关命令,报错 node-gyp… 的解决方法 相关的异常信息 通用的解决方案 1. 在线安装,适合拥有纯净 Windows 开发环境的用户(没有安装过 Python, Visual Studio 等…) 2. 手动安装,针对拥有非纯净 Windows 开发环境的老鸟(安装过 Python, Visual Studio 等…) 查看 NPM 全局配置 总结 NPM 相关命令,报错 node-gyp… 的解决方法 'node-gyp-build' is not recognized

  • IDEA连接mysql报错的问题及解决方法

    IDEA连接mysql报错了! 本人之前使用MySQL以及后续使用mybatis和mybatisPlus都是使用sqlyog或者navicat,今天重新学习sql,看到up使用了,idea插件来连接数据库(mysql)也来学习使用了,结果出现一系类问题.本博客开始记录. ---------------------------前进的道路充满荆棘.--------------------------------------------------------------------------- 错

  • 使用MyBatisPlus自动生成代码后tomcat运行报错的问题及解决方法

    自动生成的代码 报错 解决办法:把自动xml文件中自动生成的二级缓存注释掉 总结 到此这篇关于使用MyBatisPlus自动生成代码后tomcat运行报错的问题及解决方法的文章就介绍到这了,更多相关MyBatisPlus自动生成代码tomcat运行报错内容请搜索我们以前的文章或继续浏览下面的相关文章希望大家以后多多支持我们!

  • Navicat连接mysql报错1251错误的解决方法

    本文为大家分享了Navicat连接mysql报错1251错误的解决方法,供大家参考 错误提示 出现这个原因是mysql8 之前的版本中加密规则是mysql_native_password,而在mysql8之后,加密规则是caching_sha2_password 解决办法:把mysql用户登录密码加密规则还原成mysql_native_password. 步骤: 1.打开cmd命令窗口,输入命令 mysql -uroot -p 打开MySQL数据库,然后输入密码进行登录. 2.修改加密规则 将加

  • Navicat连接mysql报错2003(10060)的解决方法

    目录 发现报错 1.MySQL的服务没有启动,这个是最常见的问题原因 2.MySQL没有远程权限 3.防火墙拦截 总结 发现报错 对于Navicat连接数据库mysql 出现报错2003(10060),如下所示报错 经过查询总结以上出现问题的主要解决方法三种: 1.MySQL的服务没有启动,这个是最常见的问题原因 WIN+R,输入services.msc打开服务管理器,找到mysql 如果显示mysql为禁用状态,可以右键启动服务,然后在Navicat重新测试连接 2.MySQL没有远程权限 1

  • tensorflow 报错unitialized value的解决方法

    Attempting to use uninitialized value mean_squared_error/total 如图: 原因一:使用了tf.metrics.mean_squared_error(labels, predictions) 解决方法: 1.将其换成tf.losses.mean_squared_error(labels, preditions) 或者 2.加一个tf.lacal_variables_initializer() 原因二:将一些节点写在了tf.Session(

  • Pycharm最全报错的原因与解决方法总结(推荐!)

    目录 前言 (一)Pycharm报错:No R interpreter defined (二)找不到指定的模板:ImportError:DDL load failed while importing ft2font: (三)pycharm中无法识别导入自己写的模块 (四)pycharm光标变粗,无法编辑代码 (五)使用Pycharm给Python程序传递参数 总结 前言 最近在使用Pycharm,在运行或者安装的过程中出现了各种各样的报错,前面已经介绍过安装pygame出现报错的解决方法.文章总

  • node.js请求HTTPS报错:UNABLE_TO_VERIFY_LEAF_SIGNATURE\的解决方法

    发现错误 最近在用Nodejs发送https请求时候,出现\"Error: UNABLE_TO_VERIFY_LEAF_SIGNATURE\"的错误,错误如下: events.js:72 throw er; // Unhandled \'error\' event ^ Error: UNABLE_TO_VERIFY_LEAF_SIGNATURE at SecurePair. (tls.js:1381:32) at SecurePair.emit (events.js:92:17) at

  • C或C++报错:ld returned 1 exit status报错的原因及解决方法

    目录 参考资料:关于Id returned 1exit status的解决办法 一.问题描述 二.个人解决 三.总结反思 C或C++报错:ld returned 1 exit status(ld返回1,退出状态) 可能是以下原因:        1)程序正在运行,无法编译,上次运行的窗口未关闭. 程序窗口重复运行没有及时关闭,存在多个打开窗口,得一个个都关闭了再编译. 2)一个项目中有多个 xx.c 文件,将多余的xx.c文件改成头文件即可. 3)有函数拼写错误,如:printf拼写成prntf

  • perl操作MongoDB报错undefined symbol: HeUTF8解决方法

    因为shell操作mongo比较麻烦,只好尝试使用perl操作mongo,perl需要操作mongodb必须先安装相应的驱动,大部分人使用cpan安装,个人觉得太麻烦,使用cpanm安装perl模块. 复制代码 代码如下: # cpanm MongoDB --> Working on MongoDB Fetching http://www.cpan.org/authors/id/F/FR/FRIEDO/MongoDB-0.702.1.tar.gz ... OK Configuring Mongo

随机推荐