1

gulp-sassを使用して特定のSCSSファイルをトランスパイルしようとした時に以下のようなエラーがでてしまいまいトランスパイルすることができません。

[16:51:18] Error: Module did not self-register.
    at Error (native)
    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/<user>/Documents/workspace/product/node_modules/gulp-sass/node_modules/node-sass/lib/index.js:211:15)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478: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/<user>/Documents/workspace/product/node_modules/gulp-sass/index.js:3:17)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
Error running task sequence: { task: 'styles:scss',
  message: 'styles:scss catch',
  duration: 0.127608784,
  hrDuration: [ 0, 127608784 ],
  err: [Error: Module did not self-register.] }

環境:

  • OS X: 10.10.2
  • python: 2.7.9
  • node: v0.12.0
  • node-gyp: v1.0.2

すでに、gulp-sassのissueには同じような問題がありまして以下の様な解決方法がありましてそれらをためしても解決しませんでした。

試した解決方法:

この問題を解決する方法をご存知の方いらっしゃいますか?よろしくお願いします

3
  • issueによると、sourcemapの出力がobjectからstringに変わったことが原因ぽい。 >gulp-sass errors when used with the current master branch of node-sass because the sourceMap output type has changed from an object to a string 参照:node-sass Breaking Change to Source Maps 2015年2月12日 17:41
  • gulp-sassのREADMEにちゃんと、gulp-sassはnodejs 0.12.0やio.jsでは動かないからgulp-sassの2.0が出るまではnodeのバージョンを上げないでねって書いてあった。- (以下引用) At the moment gulp-sass will not work with node 0.12 or io.js. gulp-sass is just a wrapper around node-sass, which implements node bindings to libsass. The maintainers of node-sass are doing their best to finish version 2.0, which will include support for node 0.12 and io.js. In the meantime, there is nothing I can do to make gulp-sass work on on anything other that node 0.10.xx. If you need to run gulp-sass, don't upgrade node until node-sass 2.0 is finalized. 2015年2月12日 17:45
  • @ento 今回の件には直接関係ありませんでした。取り除いておきます 2015年2月13日 4:40

1 件の回答 1

2

解決したので問題と一緒に整理して載せておきます。

問題

gulp-sassを実行すると、Error: Module did not self-registerというエラーが表示される

環境:

  • OX: 10.10.2
  • python: 2.7.9
  • node: v0.12.0
  • node-gyp: v1.0.2

原因

gulp-sassはnode-sassのラッパーでこれはlibsassを実行していて、sourcemapの出力がobjectからstringに変わったことで、v0.12とio.jsに対応していなかったです。

At the moment gulp-sass will not work with node 0.12 or io.js. gulp-sass is just a wrapper around node-sass, which implements node bindings to libsass. The maintainers of node-sass are doing their best to finish version 2.0, which will include support for node 0.12 and io.js. In the meantime, there is nothing I can do to make gulp-sass work on on anything other that node 0.10.xx. If you need to run gulp-sass, don't upgrade node until node-sass 2.0 is finalized.

https://github.com/dlmanning/gulp-sass/commit/5ee25e68da1805bea2c5e3da0a0ba10d80e36da2

解決方法

package.jsonのgulp-sassのバージョンを上げれば解決します。

https://github.com/dlmanning/gulp-sass/commit/314ce5c1594e541a55e5c5009fb0733c45226567

この質問に回答するには、ログインする必要があります。

求めていた回答ではありませんか? のタグが付いた他の質問を参照する。