Vue前端npm编译报错问题总结

本文总结了Vue项目中常见的npm编译错误及其解决办法,包括'node-sass'找不到模块和MSBUILD错误MSB3428。解决'node-sass'问题通常需要检查nodejs与node-sass的版本兼容性,必要时降级nodejs版本并重新编译node-sass。对于MSBUILD错误,可以通过安装.NET Framework 2.0 SDK或Microsoft Visual Studio相关组件来解决。

  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的版本不匹配兼容

解决方法:

  1. 查看报错中的地址https://github.com/sass/node-sass/releases/tag/v4.13.0,得到以下版本兼容关系:
    从上图可以看出,node-sass4.13.0支持的nodejs版本最高为13,而我本地环境版本是14,所以我本机出现以上报错;
  2. 降级nodejs版本,改为node-v10.16.0-x64.msi(有需要的可以留言,可以分享下网盘下载);
  3. 卸载14版本,安装10版本;
  4. 完成以上安装,需要对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.x

    Found 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.

  5. 完成以上步骤,则可以进行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

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值