当前位置: 首页 > 工具软件 > node-launcher > 使用案例 >

node-pre-gyp ERR! install request to https://github.com/xxx、Cannot read property ‘match‘ of undefine

丁德义
2023-12-01

问题

npm install 时遇到了一个问题,部分代码如下

node-pre-gyp ERR! install request to https://github.com/yanyiwu/nodejieba/releases/download/v2.5.2/nodejieba-v2.5.2-node-v83-win32-x64.tar.gz failed, 
reason: read ECONNRESET 
node-pre-gyp WARN Pre-built binaries not installable for nodejieba@2.5.2 and node@14.3.0 (node-v83 ABI, unknown) (falling back to source compile with 
node-gyp) 
node-pre-gyp WARN Hit error request to https://github.com/yanyiwu/nodejieba/releases/download/v2.5.2/nodejieba-v2.5.2-node-v83-win32-x64.tar.gz failed, reason: read ECONNRESET 
gyp ERR! find Python 
gyp ERR! find Python Python is not set from command line or npm configuration
gyp ERR! find Python Python is not set from environment variable PYTHON
gyp ERR! find Python checking if "python" can be used
gyp ERR! find Python - "python" is not in PATH or produced an error
gyp ERR! find Python checking if "python2" can be used
gyp ERR! find Python - "python2" is not in PATH or produced an error
gyp ERR! find Python checking if "python3" can be used
gyp ERR! find Python - "python3" is not in PATH or produced an error
gyp ERR! find Python checking if the py launcher can be used to find Python 2
gyp ERR! find Python - "py.exe" is not in PATH or produced an error
gyp ERR! find Python checking if Python is C:\Python27\python.exe
gyp ERR! find Python - "C:\Python27\python.exe" could not be run
gyp ERR! find Python checking if Python is C:\Python37\python.exe
gyp ERR! find Python - "C:\Python37\python.exe" could not be run
gyp ERR! find Python
gyp ERR! find Python **********************************************************
gyp ERR! find Python You need to install the latest version of Python.
gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
gyp ERR! find Python you can try one of the following options:
gyp ERR! find Python - Use the switch --python="C:\Path\To\python.exe"
gyp ERR! find Python   (accepted by both node-gyp and npm)
gyp ERR! find Python - Set the environment variable PYTHON
gyp ERR! find Python - Set the npm configuration variable python:
gyp ERR! find Python   npm config set python "C:\Path\To\python.exe"
gyp ERR! find Python For more information consult the documentation at:
gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
gyp ERR! find Python **********************************************************
gyp ERR! find Python
gyp ERR! configure error
gyp ERR! stack Error: Could not find any Python installation to use
gyp ERR! stack     at PythonFinder.fail (D:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-python.js:307:47)
gyp ERR! stack     at PythonFinder.runChecks (D:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-python.js:136:21)
gyp ERR! stack     at PythonFinder.<anonymous> (D:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-python.js:225:16)
gyp ERR! stack     at PythonFinder.execFileCallback (D:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-python.js:271:16)
gyp ERR! stack     at exithandler (child_process.js:310:5)
gyp ERR! stack     at ChildProcess.errorhandler (child_process.js:322:5)
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:274:12)
gyp ERR! stack     at onErrorNT (internal/child_process.js:468:16)
gyp ERR! stack     at processTicksAndRejections (internal/process/task_queues.js:84:21)

解决方案:

删除package-lock.json文件和整个node_modules文件夹,最后再执行npm install重新下载

命令(windows版)

del package-lock.json
del node_modules

总结

这次能够顺利解决这个问题主要有两点

  • 一是顺着报错提示一步一步地找出路,因为我们也不知道为什么会报错,到底怎么解决,那就努力看懂提示,可能提示里有些命令已经告诉了我们怎么解决
  • 二是在网上找到了一篇解决的文章,本来的报错是上面代码这个错误,摸索着摸索着提示了“Cannot read property 'match' of undefined”,然后找到了解决的问答,解决方案也是从这里来的
 类似资料: