Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
21
Help us understand the problem. What are the problem?

More than 3 years have passed since last update.

posted at

Ubuntuにnode-sassを入れようとしたらつまづいた話

Rubyアレルギー(超偏見)なので、Ruby製のsassを使いたくなくてnode-sassを入れようとしたらつまづいたので備忘録

インストールコマンドは以下になるんですが。。。
npm install -g node-sass

実行すると、このようなエラーが。。。

gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/node-sass/build'
gyp ERR! System Linux 4.4.0-83-generic
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/node-sass/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /usr/local/lib/node_modules/node-sass
gyp ERR! node -v v8.1.4
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.5.3 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the node-sass@4.5.3 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!     /home/(ユーザー名)/.npm/_logs/2017-07-16T08_46_15_890Z-debug.log

permission denied?

ということで、sudoを付けて再度実施してみましたが変わらず。。。

いろいろ調べながら、バージョンアップとかキャッシュクリーンしてみたけど変わらず。。。

最終的に以下2コマンドを実施して、再度インストールを試みたら入ったっぽい。。。
結局、原因は分からず。。。

npm config set user 0
npm config set unsafe-perm true

実施した全コマンド

npm cache clean -f
npm install -g npm
npm install -g n
n latest
npm install -g node-gyp
npm config set user 0
npm config set unsafe-perm true
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
21
Help us understand the problem. What are the problem?