npm ERR command failednpm ERR command CWINDOWSsystem32cmd.exe d s c node-gyp rebuild

40 篇文章 0 订阅

今天下午使用npm下载websocket时遇到了一个错误,可能是我实战经验太少了,这个错误找了一个多小时。在这过程中升级了node的版本、又重新安装了淘宝镜像…一系列,主要是刚开始我以为我之前安装的python已经配置好环境变量(我之前上课的时候一直都有在用python,所以没有理由怀疑这个),而且我主观的以为这刚python应该没有多大的关系,于是就在那些细节末节的错误中找错,结果找了…。

具体错误如下:

npm ERR! code 1
npm ERR! path F:ueprojectecharts_demokoa_server
ode_modulesufferutil
npm ERR! command failed
npm ERR! command C:WINDOWSsystem32cmd.exe /d /s /c node-gyp rebuild
npm ERR! ????????????????????????????????ò???????????????/m???????
npm ERR!   bufferutil.c
npm ERR!   win_delay_load_hook.cc
npm ERR! C:\Users\ASUS\AppData\Local

ode-gyp\Cache\10.22.1\x64
ode.lib : fatal error LNK1107: invalid or corrupt file: cannot read at 0x433943 [F:ueprojectecharts_demokoa_server
ode_modulesufferutiluildufferutil.vcxproj]
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@7.1.2
npm ERR! gyp info using node@10.22.1 | win32 | x64
npm ERR! gyp info find Python using Python version 3.8.0 found at “F:python38python.exe”
npm ERR! gyp info find VS using VS2015 (14.0) found at:
npm ERR! gyp info find VS “C:Program Files (x86)Microsoft Visual Studio 14.0”
npm ERR! gyp info find VS run with --verbose for detailed information
npm ERR! gyp info spawn F:python38python.exe
npm ERR! gyp info spawn args [ ‘D:\Program Files
odejs
ode_global
ode_modules
pm
ode_modules
ode-gyp\gyp\gyp_main.py’,
npm ERR! gyp info spawn args ‘binding.gyp’,
npm ERR! gyp info spawn args ‘-f’,
npm ERR! gyp info spawn args ‘msvs’,
npm ERR! gyp info spawn args ‘-I’,
npm ERR! gyp info spawn args ‘F:\vueproject\echarts_demo\koa_server
ode_modules\bufferutil\build\config.gypi’,
npm ERR! gyp info spawn args ‘-I’,
npm ERR! gyp info spawn args ‘D:\Program Files
odejs
ode_global
ode_modules
pm
ode_modules
ode-gyp\addon.gypi’,
npm ERR! gyp info spawn args ‘-I’,
npm ERR! gyp info spawn args ‘C:\Users\ASUS\AppData\Local
ode-gyp\Cache\10.22.1\include
ode\common.gypi’,
npm ERR! gyp info spawn args ‘-Dlibrary=shared_library’,
npm ERR! gyp info spawn args ‘-Dvisibility=default’,
npm ERR! gyp info spawn args ‘-Dnode_root_dir=C:\Users\ASUS\AppData\Local
ode-gyp\Cache\10.22.1’,
npm ERR! gyp info spawn args ‘-Dnode_gyp_dir=D:\Program Files
odejs
ode_global
ode_modules
pm
ode_modules
ode-gyp’,
npm ERR! gyp info spawn args ‘-Dnode_lib_file=C:\Users\ASUS\AppData\Local
ode-gyp\Cache\10.22.1\<(target_arch)
ode.lib’,
npm ERR! gyp info spawn args ‘-Dmodule_root_dir=F:\vueproject\echarts_demo\koa_server
ode_modules\bufferutil’,
npm ERR! gyp info spawn args ‘-Dnode_engine=v8’,
npm ERR! gyp info spawn args ‘–depth=.’,
npm ERR! gyp info spawn args ‘–no-parallel’,
npm ERR! gyp info spawn args ‘–generator-output’,
npm ERR! gyp info spawn args ‘F:\vueproject\echarts_demo\koa_server
ode_modules\bufferutil\build’,
npm ERR! gyp info spawn args ‘-Goutput_dir=.’ ]
npm ERR! gyp info spawn C:Program Files (x86)MSBuild .0inMSBuild.exe
npm ERR! gyp info spawn args [ ‘build/binding.sln’,
npm ERR! gyp info spawn args ‘/clp:Verbosity=minimal’,
npm ERR! gyp info spawn args ‘/nologo’,
npm ERR! gyp info spawn args ‘/p:Configuration=Release;Platform=x64’ ]
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: C:Program Files (x86)MSBuild .0inMSBuild.exe failed with exit code: 1
npm ERR! gyp ERR! stack at ChildProcess.onExit (D:Program Files
odejs
ode_global
ode_modules
pm
ode_modules
ode-gyplibuild.js:194:23)
npm ERR! gyp ERR! stack at ChildProcess.emit (events.js:198:13)
npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
npm ERR! gyp ERR! System Windows_NT 10.0.17134
npm ERR! gyp ERR! command “D:
vm
odejs
ode.exe” “D:\Program Files
odejs
ode_global
ode_modules
pm
ode_modules
ode-gyp\bin
ode-gyp.js” “rebuild”
npm ERR! gyp ERR! cwd F:ueprojectecharts_demokoa_server
ode_modulesufferutil
npm ERR! gyp ERR! node -v v10.22.1
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     D:Program Files
odejs
ode_cache_logs?1-06-21T07_13_10_307Z-debug.log

问题归根结底是我之前安装的python没有配置环境变量。

解决方法

1、window+R打开cmd命令窗口。

2、输入npm install -g node-gyp。

3、cmd配置以来,输入npm config set python python3.8.0(python根据自己电脑的版本)。

4、配置python环境变量。右键计算机打开属性,分别点击高级系统配置、环境变量,在系统环境变量中选择Path,然后点击右下角的编辑,最终进入以下这个界面。

最后根据python在自己电脑上安装的位置进行配置,我的安装位置是在:F:python38。

5、在cmd命令窗口中输入python,如果出现以下结果则说明环境配置成功。

6、在cmd窗口中输入node-gyp list,出现以下结果,则说明安装成功。

最后就可以成功的使用npm下载第三方插件啦。

参考文章

https://blog.csdn.net/weixin_30600503/article/details/101811489

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值