nodebrew install が Failed to create the file と怒られる。

新しいMacにNode環境を整えようとnodebrewを入れたら、上手く入らなかったので解決方法をメモ。

nodebrewをinstall

まずは普通にHomebrewでnodebrewをinstall。これは問題無く終わる。

$ brew install nodebrew
$ nodebrew
nodebrew 0.9.2

Usage:
    nodebrew help                         Show this message
    nodebrew install <version>            Download and install a <version> (compile from source)
    nodebrew install-binary <version>     Download and install a <version> (binary file)
    nodebrew uninstall <version>          Uninstall a version
    nodebrew use <version>                Use <version>
    nodebrew list                         List installed versions
    nodebrew ls                           Alias for `list`
    nodebrew ls-remote                    List remote versions
    nodebrew ls-all                       List remote and installed versions
    nodebrew alias <key> <version>        Set alias to version
    nodebrew unalias <key>                Remove alias
    nodebrew clean <version> | all        Remove source file
    nodebrew selfupdate                   Update nodebrew
    nodebrew migrate-package <version>    Install global NPM packages contained in <version> to current version
    nodebrew exec <version> -- <command>  Execute <command> specified <version>

Example:
    # install from binary
    nodebrew install-binary v0.10.22

    # use a specific version number
    nodebrew use v0.10.22

    # io.js
    nodebrew install-binary io@v1.0.0
    nodebrew use io@v1.0.0

Node.jsをinstall

v4.xをインストールしてみる。

$ nodebrew install v4
fetch: http://nodejs.org/dist/v4.2.4/node-v4.2.4.tar.gz
Warning: Failed to create the file
Warning: /Users/a14162/.nodebrew/src/v4.2.4/node-v4.2.4.tar.gz: No such file
Warning: or directory

curl: (23) Failed writing body (0 != 7945)
download faild: http://nodejs.org/dist/v4.2.4/node-v4.2.4.tar.gz

ディレクトリが無いと怒られるので、mkdirをしてから再挑戦。

$ mkdir ~/.nodebrew
$ mkdir ~/.nodebrew/src
$ nodebrew install v4
$ nodebrew ls
v4.2.4

current: none

問題無くインストール終了。

Node.jsHomebrewMac