Help us understand the problem. What is going on with this article?

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

More than 3 years have passed since last update.

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
f-a24
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
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  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
ユーザーは見つかりませんでした