React-Native npm 我抛出 node-gyp 错误

问题描述 投票:0回答:1

我已经在一个项目上工作了一段时间,从未遇到过任何环境问题。 今天我不得不将项目移动到另一个目录,因此我删除了它并将其克隆到其他地方。 这就是问题开始的地方。我无法运行 npm install,即使我的 package.json 中没有 Sharp,我也会收到 node_modules/sharp 错误。
完整错误日志:

npm ERR! code 1
npm ERR! path E:\snk\node_modules\sharp
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)
npm ERR! sharp: Using cached C:\Users\Michal\AppData\Local\npm-cache\_libvips\libvips-8.14.5-win32-x64.tar.br
npm ERR! sharp: Integrity check passed for win32-x64
npm ERR! sharp: Creating E:\snk\node_modules\sharp\build\Release
npm ERR! sharp: Copying DLLs from E:\snk\node_modules\sharp\vendor\8.14.5\win32-x64\lib to E:\snk\node_modules\sharp\build\Release
npm ERR! 'prebuild-install' is not recognized as an internal or external command,
npm ERR! operable program or batch file.
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | win32 | x64
npm ERR! gyp info find Python using Python version 3.12.3 found at "C:\Python312\python.exe"
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS msvs_version not set from command line or npm config
npm ERR! gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
npm ERR! gyp ERR! find VS checking VS2022 (17.9.34728.123) found at:
npm ERR! gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools"
npm ERR! gyp ERR! find VS - found "Visual Studio C++ core features"
npm ERR! gyp ERR! find VS - found VC++ toolset: v143
npm ERR! gyp ERR! find VS - missing any Windows SDK
npm ERR! gyp ERR! find VS checking VS2019 (16.11.34729.46) found at:
npm ERR! gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools"
npm ERR! gyp ERR! find VS - found "Visual Studio C++ core features"
npm ERR! gyp ERR! find VS - found VC++ toolset: v142
npm ERR! gyp ERR! find VS - missing any Windows SDK
npm ERR! gyp ERR! find VS could not find a version of Visual Studio 2017 or newer to use
npm ERR! gyp ERR! find VS not looking for VS2015 as it is only supported up to Node.js 18
npm ERR! gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS **************************************************************
npm ERR! gyp ERR! find VS You need to install the latest version of Visual Studio
npm ERR! gyp ERR! find VS including the "Desktop development with C++" workload.
npm ERR! gyp ERR! find VS For more information consult the documentation at:
npm ERR! gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
npm ERR! gyp ERR! find VS **************************************************************
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Could not find any Visual Studio installation to use
npm ERR! gyp ERR! stack at VisualStudioFinder.fail (C:\Users\Michal\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:113:11)
npm ERR! gyp ERR! stack at VisualStudioFinder.findVisualStudio (C:\Users\Michal\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:69:17)
npm ERR! gyp ERR! stack at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
npm ERR! gyp ERR! stack at async createBuildDir (C:\Users\Michal\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\configure.js:69:26)
npm ERR! gyp ERR! stack at async run (C:\Users\Michal\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js:81:18)
npm ERR! gyp ERR! System Windows_NT 10.0.19045
npm ERR! gyp ERR! command "D:\\Program Files\\Nodejs\\node.exe" "C:\\Users\\Michal\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd E:\snk\node_modules\sharp
npm ERR! gyp ERR! node -v v21.7.3
npm ERR! gyp ERR! node-gyp -v v10.0.1
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in: C:\Users\Michal\AppData\Local\npm-cache\_logs\2024-04-12T01_47_32_159Z-debug-0.log

我尝试使用

npm i -g windows-build-tools
,但这引发了另一个错误,解决了这个错误导致了进一步的问题,所以我摆脱了那个兔子洞

node.js react-native npm
1个回答
0
投票

您是否通过choco install python visualstudio2022-workload-vctools -y安装了

workload-vctools

© www.soinside.com 2019 - 2024. All rights reserved.