Module build failed (from ./node_modules/sass-loader/dist/cjs.js)问题记录

常见问题:

  • vue项目中不同分支的包装的不一样,导致了在切换分支时遇到问题。
  • 还有在拉取新项目安装依赖包,最后dev或serve启动项目时出现错误。
	Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
	Error: Missing binding …\node_modules\node-sass\vendor\win32-x64-83\binding.node
	Node Sass could not find a binding for your current environment: Windows 64-bit with Node.js 14.x
	Found bindings for the following environments:
	Windows 64-bit with Node.js 12.x
	Syntax Error: ModuleError: Module Error (from ./node_modules/sass-loader/dist/cjs.js):
	Node Sass does not yet support your current environment: Windows 64-bit with Unsupported runtime (93)
	For more information on which environments are supported please see:
	https://github.com/sass/node-sass/releases/tag/v5.0.0

可能还会有其他的情况…这里只是简单列举经常遇见的2种。

问题原因:

  • 通常是使用npm install在网络不好的情况下丢包引起的
  • 或者是node-sass在运行后node环境发生了变化

解决方案:

  • 一般可以使用cnpm install或者yarn install安装依赖
  • npm rebuild node-sass或者cnpm install node-sass