1. 在线安装,适合拥有纯净 Windows 开发环境的用户(没有安装过 Python, Visual Studio 等…)
2. 手动安装,针对拥有非纯净 Windows 开发环境的老鸟(安装过 Python, Visual Studio 等…)
查看 NPM 全局配置
总结
NPM 相关命令,报错 node-gyp… 的解决方法
'node-gyp-build' is not recognized as an internal or external command, operable program or batch file.
npm ERR! gyp verb `which` failed Error: not found: python2
…
相关的异常信息
> node-gyp-build
errorOut='node-gyp-build' is not recognized as an internal or external command, operable program or batch file. npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! utf-8-validate@5.0.9 install: `node-gyp-build` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the utf-8-validate@5.0.9 install script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in: npm ERR! D:\app\nodejs\npm-cache\_logs\2022-06-10T00_53_04_766Z-debug.log
command='D:\app\nodejs\node.exe' 'D:\app\nvm\v14.7.0\node_modules\npm\bin\npm-cli.js' rebuild utf-8-validate@5.0.9 workingDir= npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! lx-music-desktop@1.22.0-beta pack:dir: `node build-config/pack.js && electron-builder --dir` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the lx-music-desktop@1.22.0-beta pack:dir script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in: npm ERR! D:\app\nodejs\npm-cache\_logs\2022-06-10T00_53_04_842Z-debug.log
通用的解决方案
1. 在线安装,适合拥有纯净 Windows 开发环境的用户(没有安装过 Python, Visual Studio 等…)
2. 手动安装,针对拥有非纯净 Windows 开发环境的老鸟(安装过 Python, Visual Studio 等…)
重点注意: 等到 Starting installation... 命令字样出现后,立马 Ctrl + C 终止后面的安装过程 !!! 因为我们必须自定义安装这两个新环境,才能不影响我们系统中已安装的 python 和 vs 等环境。
巧妙获取 python2 和 msvs_version 相关版本的安装包
$ npm install --global --production windows-build-tools
npm WARN deprecated windows-build-tools@5.2.2: Node.js now includes build tools for Windows. You probably no longer need this tool. See github.com/felixrieseberg/windows-build-tools for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See v8.dev/blog/math-random for details.
> windows-build-tools@5.2.2 postinstall D:\app\nodejs\node_global\node_modules\windows-build-tools
> node ./dist/index.js
Downloading python-2.7.15.amd64.msi
[============================================>] 100.0% of 20.2 MB (9 MB/s)
Downloaded python-2.7.15.amd64.msi. Saved to C:\Users\cpw\.windows-build-tools\python-2.7.15.amd64.msi.
Downloading vs_BuildTools.exe
[============================================>] 100.0% of 1.12 MB (1.12 MB/s)
Downloaded vs_BuildTools.exe. Saved to C:\Users\cpw\.windows-build-tools\vs_BuildTools.exe.
Starting installation...
Launched installers, now waiting for them to finish.
This will likely take some time - please be patient!
Status from the installers:
---------- Visual Studio Build Tools ----------
Still waiting for installer log file...
------------------- Python --------------------
Still waiting for installer log file...^C
手动安装 python2 和 msvs_version 到自定义目录
# 静默安装 python2 到指定的目录
Microsoft Windows [版本 10.0.19044.1706]
(c) Microsoft Corporation。保留所有权利。
C:\Users\cpw\.windows-build-tools>msiexec /a C:\Users\cpw\.windows-build-tools\python-2.7.15.amd64.msi /quiet TargetDir="C:/app/pvm/v2.7.15"
# 静默安装 vs_BuildTools 到默认的目录
C:\Users\cpw\.windows-build-tools>vs_BuildTools.exe /quiet PrependPath=0 Include_launcher=0 Include_test=0 Include_tcltk=0 Shortcuts=0
1. 在线安装,适合拥有纯净 Windows 开发环境的用户(没有安装过 Python, Visual Studio 等…)
2. 手动安装,针对拥有非纯净 Windows 开发环境的老鸟(安装过 Python, Visual Studio 等…)
查看 NPM 全局配置
总结
NPM 相关命令,报错 node-gyp… 的解决方法
'node-gyp-build' is not recognized as an internal or external command, operable program or batch file.
npm ERR! gyp verb `which` failed Error: not found: python2
…
相关的异常信息
> node-gyp-build
errorOut='node-gyp-build' is not recognized as an internal or external command, operable program or batch file. npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! utf-8-validate@5.0.9 install: `node-gyp-build` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the utf-8-validate@5.0.9 install script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in: npm ERR! D:\app\nodejs\npm-cache\_logs\2022-06-10T00_53_04_766Z-debug.log
command='D:\app\nodejs\node.exe' 'D:\app\nvm\v14.7.0\node_modules\npm\bin\npm-cli.js' rebuild utf-8-validate@5.0.9 workingDir= npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! lx-music-desktop@1.22.0-beta pack:dir: `node build-config/pack.js && electron-builder --dir` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the lx-music-desktop@1.22.0-beta pack:dir script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in: npm ERR! D:\app\nodejs\npm-cache\_logs\2022-06-10T00_53_04_842Z-debug.log
通用的解决方案
1. 在线安装,适合拥有纯净 Windows 开发环境的用户(没有安装过 Python, Visual Studio 等…)
2. 手动安装,针对拥有非纯净 Windows 开发环境的老鸟(安装过 Python, Visual Studio 等…)
重点注意: 等到 Starting installation... 命令字样出现后,立马 Ctrl + C 终止后面的安装过程 !!! 因为我们必须自定义安装这两个新环境,才能不影响我们系统中已安装的 python 和 vs 等环境。
巧妙获取 python2 和 msvs_version 相关版本的安装包
$ npm install --global --production windows-build-tools
npm WARN deprecated windows-build-tools@5.2.2: Node.js now includes build tools for Windows. You probably no longer need this tool. See github.com/felixrieseberg/windows-build-tools for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See v8.dev/blog/math-random for details.
> windows-build-tools@5.2.2 postinstall D:\app\nodejs\node_global\node_modules\windows-build-tools
> node ./dist/index.js
Downloading python-2.7.15.amd64.msi
[============================================>] 100.0% of 20.2 MB (9 MB/s)
Downloaded python-2.7.15.amd64.msi. Saved to C:\Users\cpw\.windows-build-tools\python-2.7.15.amd64.msi.
Downloading vs_BuildTools.exe
[============================================>] 100.0% of 1.12 MB (1.12 MB/s)
Downloaded vs_BuildTools.exe. Saved to C:\Users\cpw\.windows-build-tools\vs_BuildTools.exe.
Starting installation...
Launched installers, now waiting for them to finish.
This will likely take some time - please be patient!
Status from the installers:
---------- Visual Studio Build Tools ----------
Still waiting for installer log file...
------------------- Python --------------------
Still waiting for installer log file...^C
手动安装 python2 和 msvs_version 到自定义目录
# 静默安装 python2 到指定的目录
Microsoft Windows [版本 10.0.19044.1706]
(c) Microsoft Corporation。保留所有权利。
C:\Users\cpw\.windows-build-tools>msiexec /a C:\Users\cpw\.windows-build-tools\python-2.7.15.amd64.msi /quiet TargetDir="C:/app/pvm/v2.7.15"
# 静默安装 vs_BuildTools 到默认的目录
C:\Users\cpw\.windows-build-tools>vs_BuildTools.exe /quiet PrependPath=0 Include_launcher=0 Include_test=0 Include_tcltk=0 Shortcuts=0