gulp導入でハマったときの対処メモ


gulpのインストール時

インストールは下記のコマンドで

qiita.rb
$ sudo npm install gulp-sass --save-dev

下のようなエラーが出ていた

qiita.rb
gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/Users/***/.nodebrew/node/v9.4.0/lib/node_modules/gulp-sass/node_modules/node-sass/build'
gyp ERR! System Darwin 15.6.0
gyp ERR! command "/Users/***/.nodebrew/node/v9.4.0/bin/node" "/Users/***/.nodebrew/node/v9.4.0/lib/node_modules/gulp-sass/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/***/.nodebrew/node/v9.4.0/lib/node_modules/gulp-sass/node_modules/node-sass
gyp ERR! node -v v9.4.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok 
Build failed with error code: 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.7.2 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the node-sass@4.7.2 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/***/.npm/_logs/2018-01-12T09_08_16_651Z-debug.log

下記コマンドを打つことで解消

quiita.rb
sudo npm config set user 0
$ sudo npm config set unsafe-perm true