Vue框架可以很方便的引入各种插件,但是也因此会经常遇到种编译报错,解决起来很耗时,现在将平时遇到的一些编译报错,以及解决方法收录于此。
1、Module build failed: Error: Cannot find module 'node-sass'
问题:
Module build failed: Error: Cannot find module 'node-sass'
Module build failed: Error: Node Sass does not yet support your current environment: Windows 64-bit with Unsupported runtime (83)
For more information on which environments are supported please see:
https://github.com/sass/node-sass/releases/tag/v4.13.0
以上问题在解决的过程中,期间可能会变形的出现其它与之相关的各种问题,但报这种问题的根源可能是本地环境原因。主要是由于本地的nodejs版本与node-sass的版本不匹配兼容。
解决方法:
- 查看报错中的地址https://github.com/sass/node-sass/releases/tag/v4.13.0,得到以下版本兼容关系:
从上图可以看出,node-sass4.13.0支持的nodejs版本最高为13,而我本地环境版本是14,所以我本机出现以上报错; - 降级nodejs版本,改为node-v10.16.0-x64.msi(有需要的可以留言,可以分享下网盘下载);
- 卸载14版本,安装10版本;
- 完成以上安装,需要对node-sass进行重新编译 npm rebuild node-sass,否则无法与10版本node进行绑定,会如下错误:
Module build failed: Error: Missing binding D:\CompCode\Prod\it-portal\src\fe\node_modules\_node-sass@4.13.0@node-sass\vendor\win32-x64
-64\binding.node
Node Sass could not find a binding for your current environment: Windows 64-bit with Node.js 10.xFound bindings for the following environments:
- Windows 64-bit with Unsupported runtime (83)This usually happens because your environment has changed since running `npm install`.
Run `npm rebuild node-sass` to download the binding for your current environment. -
完成以上步骤,则可以进行npm run dev。
2、MSBUILD : error MSB3428: 未能加载 Visual C++ 组件“VCBuild.exe”
问题:
MSBUILD : error MSB3428: 未能加载 Visual C++ 组件“VCBuild.exe”。要解决此问题,1) 安装 .NET Framework 2.0 SDK;2) 安装 Microsoft Visual Stu
解决方法:
npm install --global --production windows-build-tools
本文总结了Vue项目中常见的npm编译错误及其解决办法,包括'node-sass'找不到模块和MSBUILD错误MSB3428。解决'node-sass'问题通常需要检查nodejs与node-sass的版本兼容性,必要时降级nodejs版本并重新编译node-sass。对于MSBUILD错误,可以通过安装.NET Framework 2.0 SDK或Microsoft Visual Studio相关组件来解决。
871

被折叠的 条评论
为什么被折叠?



