e a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js. npm ERR! code 1 npm ERR! path E:\code\infopublicassess-web\node_modules\node-sass npm ERR! command failed npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node scripts/build.js npm ERR! Building: D:\codeApp\nodejs\node.exe E:\code\infopublicassess-web\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library= npm ERR! gyp info it worked if it ends with ok npm ERR! gyp verb cli [ npm ERR! gyp verb cli 'D:\\codeApp\\nodejs\\node.exe', npm ERR! gyp verb cli 'E:\\code\\infopublicassess-web\\node_modules\\node-gyp\\bin\\node-gyp.js', npm ERR! gyp verb cli 'rebuild', npm ERR! gyp verb cli '--verbose', npm ERR! gyp verb cli '--libsass_ext=', npm ERR! gyp verb cli '--libsass_cflags=', npm ERR! gyp verb cli '--libsass_ldflags=', npm ERR! gyp verb cli '--libsass_library=' npm ERR! gyp verb cli ] npm ERR! gyp info using [email protected] npm ERR! gyp info using [email protected] | win32 | x64 npm ERR! gyp verb command rebuild [] npm ERR! gyp verb command clean [] npm ERR! gyp verb clean removing "build" directory npm ERR! gyp verb command configure [] npm ERR! gyp verb find Python Python is not set from command line or npm configuration npm ERR! gyp verb find Python Python is not set from environment variable PYTHON npm ERR! gyp verb find Python checking if "python3" can be used npm ERR! gyp verb find Python - executing "python3" to get executable path npm ERR! gyp verb find Python - "python3" is not in PATH or produced an error npm ERR! gyp verb find Python checking if "python" can be used npm ERR! gyp verb find Python - executing "python" to get executable path npm ERR! gyp verb find Python - executable path is "D:\codeApp\Python313\python.exe" npm ERR! gyp verb find Python - executing "D:\codeApp\Python313\python.exe" to get version npm ERR! gyp verb find Python - version is "3.13.5" npm ERR! gyp info find Python using Python version 3.13.5 found at "D:\codeApp\Python313\python.exe" npm ERR! gyp verb get node dir no --target version specified, falling back to host node version: 16.15.0 npm ERR! gyp verb command install [ '16.15.0' ] npm ERR! gyp verb install input version string "16.15.0" npm ERR! gyp verb install installing version: 16.15.0 npm ERR! gyp verb install --ensure was passed, so won't reinstall if already installed npm ERR! gyp verb install version is already installed, need to check "installVersion" npm ERR! gyp verb got "installVersion" 9 npm ERR! gyp verb needs "installVersion" 9 npm ERR! gyp verb install version is good npm ERR! gyp verb get node dir target node version installed: 16.15.0 npm ERR! gyp verb build dir attempting to create "build" dir: E:\code\infopublicassess-web\node_modules\node-sass\build npm ERR! gyp verb build dir "build" dir needed to be created? E:\code\infopublicassess-web\node_modules\node-sass\build npm ERR! gyp verb find VS msvs_version not set from command line or npm config npm ERR! gyp verb find VS VCINSTALLDIR not set, not running in VS Command Prompt npm ERR! gyp verb find VS unknown version "undefined" found at "C:\Program Files\Microsoft Visual Studio\2022\Community" npm ERR! gyp verb find VS could not find a version of Visual Studio 2017 or newer to use npm ERR! gyp verb find VS looking for Visual Studio 2015 npm ERR! gyp verb find VS - not found npm ERR! gyp verb 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 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 unknown version "undefined" found at "C:\Program Files\Microsoft Visual Studio\2022\Community" 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 looking for Visual Studio 2015 npm ERR! gyp ERR! find VS - not found 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 (E:\code\infopublicassess-web\node_modules\node-gyp\lib\find-visualstudio.js:121:47) npm ERR! gyp ERR! stack at E:\code\infopublicassess-web\node_modules\node-gyp\lib\find-visualstudio.js:74:16 npm ERR! gyp ERR! stack at VisualStudioFinder.findVisualStudio2013 (E:\code\infopublicassess-web\node_modules\node-gyp\lib\find-visualstudio.js:351:14) npm ERR! gyp ERR! stack at E:\code\infopublicassess-web\node_modules\node-gyp\lib\find-visualstudio.js:70:14 npm ERR! gyp ERR! stack at E:\code\infopublicassess-web\node_modules\node-gyp\lib\find-visualstudio.js:372:16 npm ERR! gyp ERR! stack at E:\code\infopublicassess-web\node_modules\node-gyp\lib\util.js:54:7 npm ERR! gyp ERR! stack at E:\code\infopublicassess-web\node_modules\node-gyp\lib\util.js:33:16 npm ERR! gyp ERR! stack at ChildProcess.exithandler (node:child_process:406:5) npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:527:28) npm ERR! gyp ERR! stack at maybeClose (node:internal/child_process:1092:16) npm ERR! gyp ERR! System Windows_NT 10.0.22631 npm ERR! gyp ERR! command "D:\\codeApp\\nodejs\\node.exe" "E:\\code\\infopublicassess-web\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library=" npm ERR! gyp ERR! cwd E:\code\infopublicassess-web\node_modules\node-sass npm ERR! gyp ERR! node -v v16.15.0 npm ERR! gyp ERR! node-gyp -v v7.1.2 npm ERR! gyp ERR! not ok npm ERR! Build failed with error code: 1 npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\kmxxg_123\AppData\Local\npm-cache\_logs\2025-07-01T08_25_48_985Z-debug-0.log
时间: 2025-07-15 07:36:37 浏览: 4
在 Windows 上安装 `node-sass` 时,如果遇到 `gyp ERR! stack Error: Could not find any Visual Studio installation to use` 错误,通常是因为 Node.js 的构建工具 `node-gyp` 无法找到本地的 Visual Studio 安装环境。以下是几种有效的解决方案:
### 使用 npm 配置指定 Visual Studio 版本
如果系统中已经安装了 Visual Studio(例如 VS 2019 或 VS 2022),可以通过设置 npm 的配置来明确告知 `node-gyp` 使用哪个版本的 Visual Studio。
```bash
npm config set msvs_version 2019
```
或者对于 Visual Studio 2022:
```bash
npm config set msvs_version 2022
```
执行上述命令后再次尝试安装 `node-sass`:
```bash
npm install node-sass
```
### 安装 Windows Build Tools
如果尚未安装 Windows 编译环境,可以使用以下命令安装适用于 Node.js 的编译工具链:
```bash
npm install --global --production windows-build-tools
```
此命令会自动下载并安装 Python、Visual Studio 构建工具等必要的依赖项。若由于网络问题导致下载失败,可尝试使用国内镜像源进行安装:
```bash
npm install --global --production windows-build-tools --msvs-version=2019 --python-version=3.9.0 --disturl=https://electronjs.org/headers
```
### 指定镜像源加速安装
由于官方 npm 源在国内访问较慢,推荐使用淘宝镜像或其他国内镜像源来加速安装过程:
```bash
npm install node-sass --registry=https://registry.npmmirror.com
```
此外,也可以通过指定 Sass 版本来避免兼容性问题。例如安装 `[email protected]`,这是与较新 Node.js 版本兼容性较好的一个版本[^3]:
```bash
npm install node-sass@^4.14.0 --registry=https://registry.npmmirror.com
```
### 设置 Python 环境变量
确保系统中已正确安装 Python 并将其路径加入到环境变量中。建议使用 Python 3.x 版本,并验证是否可通过命令行直接调用:
```bash
python --version
```
若提示找不到命令,请手动将 Python 可执行文件路径添加至 `PATH` 环境变量中。
### 手动配置 Visual Studio 工具集
在某些情况下,即使安装了 Visual Studio,`node-gyp` 仍可能无法识别其存在。此时可以尝试手动设置 GYP 参数以启用对应的 MSVC 工具链:
```bash
npm config set python C:\Python39\python.exe
npm config set msvs_version 2019
```
替换 `C:\Python39\python.exe` 为你本地实际的 Python 路径。
---
阅读全文
相关推荐










