MSBUILD : error MSB3428: 未能加载 Visual C++ 组件“VCBuild.exe”。
大家在npm run dev 的时候会遇到标题所示的错误,以下是解决方法:
首先:
npm install --global --production windows-build-tools
PS C:\Users\leo> 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 https://github.com/felixrieseberg/windows-build-tools for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://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 https://v8.dev/blog/math-random for details.
> windows-build-tools@5.2.2 postinstall E:\node\node_global\node_modules\windows-build-tools
> node ./dist/index.js
Downloading vs_BuildTools.exe
[> ] 0.0% (0 B/s)
Downloaded vs_BuildTools.exe. Saved to C:\Users\leo\.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 --------------------
Python 2.7.18 is already installed, not installing again.
安装:
C:\Users\leo.windows-build-tools\vs_BuildTools.exe文件
安装完成后再npm run dev还是不行。
会报错:
webpack-dev-server的–inline 参数已经不适用
那就是webpack-dev-server的版本太高了,
npm uninstall webpack-dev-server
npm install webpack-dev-server@2.9.1
就可以了,希望对你有帮助!