问题一:编译器版本差异问题,报错信息如下:
Node Sass could not find a binding for your current environment: Linux 64-bit with Node.js 10.x
Found bindings for the following environments:
- Windows 64-bit with Node.js 8.x
这个问题是版本不一致导致了,正常开发环境使用版本为windows node 8.x;使用服务器构建时采用了Linux node 10.x;
解决方案:
# 在linux 执行如下命令
npm rebuild node-sass
# 服务器内网封闭情况下
#需下载对应版本的 linux-x64-64_binding.node
#放置在工程目录下/node_modules/node-sass/vendor/linux-x64-64/
#并重命名为binding.node
问题二:编码时大小不一致导致文件找不到,报错信息如下:
ERROR in ./node_modules/fs.realpath/index.js
Module not found: Error: Can't resolve 'Fs' in '....\node_modules\fs.realpath'
Windows下对大小写不敏感,开发过程中如果引用部分与文件定义部分大小写不一致,可以正常运行;linux下对大小写敏感,如果有大小写不一致的写法会直接暴露出来,告诉你找不到文件
解决方案:
根据错误信息找到对应的文件及其引用,确认大小写的差异,修改后提交即可