npm ERR! code 1
npm ERR! path G:\yhcode\jyplatFront1\node_modules\node-sass
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c C:\Users\hui\AppData\Local\Temp\postinstall-2ccbc234.cmd
npm ERR! Building: H:\software\programming\node\nodejs\node.exe G:\yhcode\jyplatFront1\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

可能需要

因为通过直接执行安装c++环境报python网络链接超时无法顺利下载,因此先本地下载执行的安装。

node-gyp 尝试编译 node-sass 时,由于 Python 版本的问题导致失败。错误信息中提到 Python 版本是 3.12.3,但 node-gyp 通常需要 Python 2.x 或 Python 3.6 到 3.8 之间的版本。

设置python环境变量

通过npm设置python路径

设置node-gyp的js路径

然后执行

npm install --global --production windows-build-tools

可能会报python已经安装的日志,还需要去缓存文件夹新建一个dd开头的日志,具体百度即可,才可以顺利执行