跳至内容
node-gyp

node gyp Error: Could not find any Visual Studio installation to use

这两天买了M2的硬盘,重装了系统,所有项目要重新装依赖,在安装NestJS依赖的时候,遇到了臭名昭著的node-gyp报错,这个库从我很小很小的时候就知道它很臭,下面是报错信息:

gyp info it worked if it ends with ok
│ gyp info using node-gyp@9.4.0
│ gyp info using node@18.17.1 | win32 | x64
│ gyp info ok
│ gyp info it worked if it ends with ok
│ gyp info using node-gyp@9.4.0
│ gyp info using node@18.17.1 | win32 | x64
│ gyp info find Python using Python version 3.11.5 found at "C:\Users\MrYu1\AppData\Local\Programs\Python\Python311\python.exe"
│ gyp ERR! find VS
│ gyp ERR! find VS msvs_version not set from command line or npm config
│ gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
│ gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer, try re-running with '--loglevel silly' for more details
│ gyp ERR! find VS looking for Visual Studio 2015
│ gyp ERR! find VS - not found
│ gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
│ gyp ERR! find VS
│ gyp ERR! find VS **************************************************************
│ gyp ERR! find VS You need to install the latest version of Visual Studio
│ gyp ERR! find VS including the "Desktop development with C++" workload.
│ gyp ERR! find VS For more information consult the documentation at:
│ gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
│ gyp ERR! find VS **************************************************************
│ gyp ERR! find VS
│ gyp ERR! configure error
│ gyp ERR! stack Error: Could not find any Visual Studio installation to use
│ gyp ERR! stack     at VisualStudioFinder.fail (C:\Users\MrYu1\AppData\Roaming\npm\node_modules\pnpm\dist\node_modules\node-gyp\lib\find-visualstudio.js:122:47)
│ gyp ERR! stack     at C:\Users\MrYu1\AppData\Roaming\npm\node_modules\pnpm\dist\node_modules\node-gyp\lib\find-visualstudio.js:75:16
│ gyp ERR! stack     at VisualStudioFinder.findVisualStudio2013 (C:\Users\MrYu1\AppData\Roaming\npm\node_modules\pnpm\dist\node_modules\node-gyp\lib\find-visualstudio.js:380:14)
│ gyp ERR! stack     at C:\Users\MrYu1\AppData\Roaming\npm\node_modules\pnpm\dist\node_modules\node-gyp\lib\find-visualstudio.js:71:14
│ gyp ERR! stack     at C:\Users\MrYu1\AppData\Roaming\npm\node_modules\pnpm\dist\node_modules\node-gyp\lib\find-visualstudio.js:401:16
│ gyp ERR! stack     at C:\Users\MrYu1\AppData\Roaming\npm\node_modules\pnpm\dist\node_modules\node-gyp\lib\util.js:54:7
│ gyp ERR! stack     at C:\Users\MrYu1\AppData\Roaming\npm\node_modules\pnpm\dist\node_modules\node-gyp\lib\util.js:33:16
│ gyp ERR! stack     at ChildProcess.exithandler (node:child_process:427:5)
│ gyp ERR! stack     at ChildProcess.emit (node:events:514:28)
│ gyp ERR! stack     at maybeClose (node:internal/child_process:1091:16)
│ gyp ERR! System Windows_NT 10.0.22621
│ gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\MrYu1\\AppData\\Roaming\\npm\\node_modules\\pnpm\\dist\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "--fallback-to-build" "--modul…  
│ gyp ERR! cwd C:\Users\MrYu1\Desktop\CXTech\CXTechSoftware\Templates\AdminServer2023\node_modules\.pnpm\bcrypt@5.1.1\node_modules\bcrypt
│ gyp ERR! node -v v18.17.1
│ gyp ERR! node-gyp -v v9.4.0
│ gyp ERR! not ok
│ node-pre-gyp ERR! build error
│ node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\MrYu1\AppData\Roaming\npm\node_modules\pnpm\dist\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-buil…  
│ node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (C:\Users\MrYu1\Desktop\CXTech\CXTechSoftware\Templates\AdminServer2023\node_modules\.pnpm\@mapbox+node-pre-gyp@1.0.11\node_modules\@mapbox\node-pre-gy…  
│ Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\MrYu1\AppData\Roaming\npm\node_modules\pnpm\dist\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=C:\Users\MrYu1\Deskt…  
│ node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:514:28)
│ node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1091:16)
│ node-pre-gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:302:5)
│ node-pre-gyp ERR! System Windows_NT 10.0.22621
│ node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\MrYu1\\Desktop\\CXTech\\CXTechSoftware\\Templates\\AdminServer2023\\node_modules\\.pnpm\\@mapbox+node-pre-gyp@1.0.11\\node_modules\…  
│ node-pre-gyp ERR! cwd C:\Users\MrYu1\Desktop\CXTech\CXTechSoftware\Templates\AdminServer2023\node_modules\.pnpm\bcrypt@5.1.1\node_modules\bcrypt
│ node-pre-gyp ERR! node -v v18.17.1
│ node-pre-gyp ERR! node-pre-gyp -v v1.0.11
│ node-pre-gyp ERR! not ok

如果遇到这个问题,其实不需要你安装什么vs tools,我看网上一堆说需要安装,你可以试试运行:

pnpm update

先把Package Lock文件删掉,再运行上面这个命令,然后再运行install。

作者:SEO禅
本文链接:node gyp Error: Could not find any Visual Studio installation to use
版权申明:如无特殊说明,本站文章均为作者原创,著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处,谢谢!

标签:

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注