[解决node-sass报错]ENOENT: no such file or directory, scandir '*\node-sass\vendor'

在使用npm安装node-sass的时候,可能会出现如下报错:

第一种

Error: ENOENT: no such file or directory, scandir '{PATH}\node-sass\vendor'
    at Error (native)
    at Object.fs.readdirSync (fs.js:856:18)
    at Object.getInstalledBinaries ({PATH}\node_modules\.npminstall\node-sass\3.7.0\node-sass\lib\extensions.js:74:13)
    at foundBinariesList ({PATH}\node_modules\.npminstall\node-sass\3.7.0\node-sass\lib\errors.js:20:15)
    at foundBinaries ({PATH}\node_modules\.npminstall\node-sass\3.7.0\node-sass\lib\errors.js:15:5)
    at Object.module.exports.missingBinary ({PATH}\node_modules\.npminstall\node-sass\3.7.0\node-sass\lib\errors.js:45:5)
    at Object.<anonymous> ({PATH}\node_modules\.npminstall\node-sass\3.7.0\node-sass\lib\index.js:14:28)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)
    at Object.<anonymous> ({PATH}\node_modules\.npminstall\gulp-sass\2.2.0\gulp-sass\index.js:186:21)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)

第二种

Run `npm rebuild node-sass` to build the binding for your current environment.
    at module.exports ({PATH}\node_modules\node-sass\lib\binding.js:
15:13)
    at Object.<anonymous> ({PATH}\node_modules\node-sass\lib\index.j
s:14:35)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> ({PATH}\node_modules\sass-loader\lib\loade
r.js:3:14)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at loadLoader ({PATH}\node_modules\loader-runner\lib\loadLoader.
js:13:17)

解决方案是执行以下方法:

npm rebuild node-sass

Copyright © 2017-02-18 XIAOZHUO.WANG™

    原文作者:xiozho
    原文地址: https://www.jianshu.com/p/a9b5e00c6beb
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞