LoginSignup
10
7

More than 5 years have passed since last update.

Nodeの導入が上手くいかない

Posted at

はじめに

みなさんこんにちは。
昔にちょっとかじったTitaniumを再び始めようと思い勉強会に参加することにしました。しかし、TitaniumStudioが古すぎたのでアップデートしようとしたらNode無いよと怒られハマりました。
ということで、Nodeの導入時のエラーについて紹介したいと思います。

npmの確認

まずNodeのパッケージ管理ツールnpmが導入されているかチェック。(念のため入っているかどうかしてみた)

bash
$ npm -v
-bash: npm: command not found

はい、ありません笑
まずbrewnpmの導入をやってみました。

bash
$ brew install npm
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/node-0.10.32.mavericks.bottle.tar.gz
######################################################################## 100.0%
==> Pouring node-0.10.32.mavericks.bottle.tar.gz
==> Caveats
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/node
Target /usr/local/bin/node
already exists. You may want to remove it:
  rm /usr/local/bin/node

To force the link and overwrite all conflicting files:
  brew link --overwrite node

To list all files that would be deleted:
  brew link --overwrite --dry-run node

Possible conflicting files are:
/usr/local/bin/node
/usr/local/include/node/ares.h
/usr/local/include/node/ares_version.h
/usr/local/include/node/node.h
/usr/local/include/node/node_buffer.h
/usr/local/include/node/node_object_wrap.h
/usr/local/include/node/node_version.h
/usr/local/include/node/uv-private/ngx-queue.h
/usr/local/include/node/uv-private/tree.h
/usr/local/include/node/uv-private/uv-unix.h
/usr/local/include/node/uv-private/uv-win.h
/usr/local/include/node/uv.h
/usr/local/include/node/v8-debug.h
/usr/local/include/node/v8-preparser.h
/usr/local/include/node/v8-profiler.h
/usr/local/include/node/v8-testing.h
/usr/local/include/node/v8.h
/usr/local/include/node/v8stdint.h
/usr/local/share/man/man1/node.1
/usr/local/lib/dtrace/node.d
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall node`
==> Summary
?  /usr/local/Cellar/node/0.10.32: 1678 files, 19M

こんな感じでエラーが出てしまいました。
Nodeを入れてみようとしてもこの通り。

bash
$ brew postinstall node
Error: Permission denied - /usr/local/lib/node_modules/npm/AUTHORS

エラー文にあるbrew linkのコマンドを実行してみましたが結局ダメでした。

原因...?

おそらく原因は余計なファイルがあったことと、ディレクトリのアクセス権限が無かったことだと思います。一部ごちゃごちゃしてしまったのではっきりとはわからずですが汗

解決方法

最終的にはエラー文に載ってるNode関連ファイルをrmで消しました(/usr/local/include/nodeとか)。力技です。
一部は所有者を変更しました。例としてはこんな感じ。

bash
$ sudo chown -R user:group /usr/local/lib/node_modules

最後はroot権限でbrewすればokです。

bash
$ sudo brew postinstall node

これで無事Nodeが入りました。

bash
$ node -v
v0.10.32

おわりに

時間がかかってしまいましたがNodeの導入が出来ました。
そして...本題のTitaniumStudioのアップデートも出来ましたw
TitaniumStudioの導入がもっと簡単になるといいですね。
今回は以下の記事を参考にさせて頂ました。ありがとうございます。

brewでnode.jsをインストールするのがつらかった
http://www.misakit.com/post/92519432276/brew-node-js

10
7
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
7