这种情况一般是安装了nvm的情况下会出现,错误提示一般如下
Progress: resolved 1713, reused 1633, downloaded 0, added 1632, done
node_modules/.pnpm/[email protected]/node_modules/core-js: Running postinstall script, done in 118ms
node_modules/.pnpm/[email protected]/node_modules/core-js: Running postinstall script, done in 155ms
node_modules/.pnpm/[email protected]/node_modules/deasync: Running install script, failed in 44.5s
.../[email protected]/node_modules/deasync install$ node ./build.js
│ F:\vue3-admin-template\node_modules\.pnpm\[email protected]\node_modules\deasync>if not defined npm_c
│ gyp info it worked if it ends with ok
│ gyp info using [email protected]
│ gyp info using [email protected] | win32 | ia32
│ gyp info find Python using Python version 3.8.0 found at "D:\tools\Python38-32\python.exe"
│ gyp http GET https://nodejs.org/download/release/v18.19.0/node-v18.19.0-headers.tar.gz
│ gyp http 200 https://nodejs.org/download/release/v18.19.0/node-v18.19.0-headers.tar.gz
│ gyp http GET https://nodejs.org/download/release/v18.19.0/SHASUMS256.txt
│ gyp http GET https://nodejs.org/download/release/v18.19.0/win-x86/node.lib
│ gyp http GET https://nodejs.org/download/release/v18.19.0/win-x64/node.lib
│ gyp http GET https://nodejs.org/download/release/v18.19.0/win-arm64/node.lib
│ gyp http 200 https://nodejs.org/download/release/v18.19.0/SHASUMS256.txt
│ gyp http 200 https://nodejs.org/download/release/v18.19.0/win-x64/node.lib
│ gyp http 200 https://nodejs.org/download/release/v18.19.0/win-x86/node.lib
│ gyp http 404 https://nodejs.org/download/release/v18.19.0/win-arm64/node.lib
│ 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
│ 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 (D:\tools\nvm\v18.19.0\node_modules\pnpm\dist\node_modules\node-gyp\li
│ gyp ERR! stack at D:\tools\nvm\v18.19.0\node_modules\pnpm\dist\node_modules\node-gyp\lib\find-visualstudio.js:75
│ gyp ERR! stack at VisualStudioFinder.findVisualStudio2013 (D:\tools\nvm\v18.19.0\node_modules\pnpm\dist\node_mod
│ gyp ERR! stack at D:\tools\nvm\v18.19.0\node_modules\pnpm\dist\node_modules\node-gyp\lib\find-visualstudio.js:71
│ gyp ERR! stack at D:\tools\nvm\v18.19.0\node_modules\pnpm\dist\node_modules\node-gyp\lib\find-visualstudio.js:38
│ gyp ERR! stack at D:\tools\nvm\v18.19.0\node_modules\pnpm\dist\node_modules\node-gyp\lib\util.js:54:7
│ gyp ERR! stack at D:\tools\nvm\v18.19.0\node_modules\pnpm\dist\node_modules\node-gyp\lib\util.js:33:16
│ gyp ERR! stack at ChildProcess.exithandler (node:child_process:430:5)
│ gyp ERR! stack at ChildProcess.emit (node:events:517:28)
│ gyp ERR! stack at maybeClose (node:internal/child_process:1098:16)
│ gyp ERR! System Windows_NT 10.0.19045
│ gyp ERR! command "D:\\tools\\nodejs\\node.exe" "D:\\tools\\nvm\\v18.19.0\\node_modules\\pnpm\\dist\\node_modules\\no
│ gyp ERR! cwd F:\vue3-admin-template\node_modules\.pnpm\[email protected]\node_modules\deasync
│ gyp ERR! node -v v18.19.0
│ gyp ERR! node-gyp -v v8.4.1
│ gyp ERR! not ok
│ Build failed
└─ Failed in 44.5s
node_modules/.pnpm/[email protected][email protected]/node_modules/vue-demi: Running postinstall script, done in 416ms
ELIFECYCLE Command failed with exit code 1.
有时候用npm安装也会出现这样的错误,错误发生的原因好像是node的版本引起的, 我这里安装的是 18.19.0 32位版本的,
使用nvm重新安装一个 18.19.0 64位版本的就不报错了,特记录一下