gulpを実行したらnode-sassでエラー
原因は、node.jsのバージョンが変わってしまったことにあるようです。
今後も起こりそうでしたので備忘録として記載しておきます。
エラー文は下記のような内容。
Error
[17:19:50] 'sass' errored after 407 ms
[17:19:50] Error: The `libsass` binding was not found in /Users/hogehoge/node_modules/gulp-sass/node_modules/node-sass/vendor/darwin-x64-46/binding.node
This usually happens because your node version has changed.
Run `npm rebuild node-sass` to build the binding for your current node version.
at Object.sass.getBinaryPath (/Users/hogehoge/node_modules/gulp-sass/node_modules/node-sass/lib/extensions.js:158:11)
at Object.<anonymous> (/Users/hogehoge/node_modules/gulp-sass/node_modules/node-sass/lib/index.js:16:36)
at Module._compile (module.js:434:26)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/Users/hogehoge/node_modules/gulp-sass/index.js:183:21)
at Module._compile (module.js:434:26)
etc....
バージョンが合わなくて使うライブラリがないですよという感じでしょうか。
解決方法
Error
Run `npm rebuild node-sass` to build the binding for your current node version.
rebuildしてくれと表示されているので実行する。
$ npm rebuild node-sass
> node-sass@3.4.2 install /Users/hogehoge/node_modules/gulp-sass/node_modules/node-sass
> node scripts/install.js
Binary downloaded and installed at /Users/hogehoge/node_modules/gulp-sass/node_modules/node-sass/vendor/darwin-x64-46/binding.node
> node-sass@3.4.2 postinstall /Users/hogehoge/node_modules/gulp-sass/node_modules/node-sass
> node scripts/build.js
` /Users/hogehoge/node_modules/gulp-sass/node_modules/node-sass/vendor/darwin-x64-46/binding.node ` exists.
testing binary.
Binary is fine; exiting.
node-sass@3.4.2 /Users/hogehoge/node_modules/gulp-sass/node_modules/node-sass
$ gulp
こちらでbuildされたので再度、gulpを走らせればOKです。