开始用到React Native for iOS,特此笔记。
如能帮助到您,我会很开心。
- OS X - 当前仅支持 OS X
- 推荐使用 Homebrew 的方式来安装 nvm,watchman 和 flow。
MacdeiMac:~ mac$ ruby -v
ruby 2.0.0p645 (2015-04-13 revision 50299) [universal.x86_64-darwin15]
MacdeiMac:~ mac$ pwd
/Users/mac
MacdeiMac:~ mac$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
==> This script will install:
/usr/local/bin/brew
/usr/local/Library/...
/usr/local/share/man/man1/brew.1
==> The following directories will be made group writable:
/usr/local/.
/usr/local/bin
==> The following directories will have their owner set to mac:
/usr/local/.
/usr/local/bin
==> The following directories will have their group set to admin:
/usr/local/.
/usr/local/bin
Press RETURN to continue or any other key to abort
按回车
==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/. /usr/local/bin
WARNING: Improper use of the sudo command could lead to data loss
or the deletion of important system files. Please double-check your
typing when using sudo. Type "man sudo" for more information.
To proceed, enter your password, or type Ctrl-C to abort.
Password:输密码,回车
==> /usr/bin/sudo /usr/sbin/chown mac /usr/local/. /usr/local/bin
==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/. /usr/local/bin
==> /usr/bin/sudo /bin/mkdir /Library/Caches/Homebrew
==> /usr/bin/sudo /bin/chmod g+rwx /Library/Caches/Homebrew
==> /usr/bin/sudo /usr/sbin/chown mac /Library/Caches/Homebrew
==> Downloading and installing Homebrew...
remote: Counting objects: 3847, done.
remote: Compressing objects: 100% (3691/3691), done.
remote: Total 3847 (delta 39), reused 660 (delta 21), pack-reused 0
Receiving objects: 100% (3847/3847), 3.34 MiB | 215.00 KiB/s, done.
Resolving deltas: 100% (39/39), done.
From https://github.com/Homebrew/homebrew
* [new branch] master -> origin/master
HEAD is now at fa338a5 notmuch: add mirror, improve emacs build
==> Installation successful!
==> Next steps
Run `brew help` to get started
输入 brew help 看看
MacdeiMac:~ mac$ brew help
Example usage:
brew [info | home | options ] [FORMULA...]
brew install FORMULA...
brew uninstall FORMULA...
brew search [foo]
brew list [FORMULA...]
brew update
brew upgrade [FORMULA...]
brew pin/unpin [FORMULA...]
Troubleshooting:
brew doctor
brew install -vd FORMULA
brew [--env | config]
Brewing:
brew create [URL [--no-fetch]]
brew edit [FORMULA...]
https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Formula-Cookbook.md
Further help:
man brew
brew home
安装任何东西前要运行 brew doctor 看看
MacdeiMac:~ mac$ brew doctor
Your system is ready to brew. 这样说明ok
使用 Homebrew 来安装 nvm
MacdeiMac:~ mac$ brew install nvm
==> Downloading https://github.com/creationix/nvm/archive/v0.29.0.tar.gz
==> Downloading from https://codeload.github.com/creationix/nvm/tar.gz/v0.29.0
######################################################################## 100.0%
==> Caveats
Please note that upstream has asked us to make explicit managing
nvm via Homebrew is unsupported by them and you should check any
problems against the standard nvm install method prior to reporting.
You should create NVM's working directory if it doesn't exist:
mkdir ~/.nvm
Add the following to ~/.bash_profile or your desired shell
configuration file:
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh
You can set $NVM_DIR to any location, but leaving it unchanged from
/usr/local/Cellar/nvm/0.29.0 will destroy any nvm-installed Node installations
upon upgrade/reinstall.
Type `nvm help` for further information.
Bash completion has been installed to:
/usr/local/etc/bash_completion.d
==> Summary
�� /usr/local/Cellar/nvm/0.29.0: 6 files, 96K, built in 9 seconds
安装nvm成功,但当你输入nvm -v
MacdeiMac:~ mac$ nvm -v
-bash: nvm: command not found
会告诉你不能调用,仔细看上面的文字,还需要做一些设置
来自:http://www.jb51.net/article/73424.htm nvm 重启后终端 node ,npm 失效的解决方案
如果你使用了上面的 brew 的安装方法
当安装成功后,请按照如下操作设置你的 shell 配置文件
1 |
brew info nvm |
你会看到下面的输出帮助信息
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
nvm: stable 0.26.1 (bottled), HEAD Manage multiple Node.js versions https://github.com/creationix/nvm /usr/local/Cellar/nvm/0.26.1 (3173 files, 56M) * Poured from bottle From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/nvm.rb ==> Caveats Add NVM's working directory to your $HOME path (if it doesn't exist):
mkdir ~/.nvm
Copy nvm-exec to NVM's working directory
cp $(brew --prefix nvm)/nvm-exec ~/.nvm/
Add the following to $HOME/.bashrc, $HOME/.zshrc, or your shell's equivalent configuration file:
export NVM_DIR=~/.nvm source $(brew --prefix nvm)/nvm.sh
Type `nvm help` for further information.
Bash completion has been installed to: /usr/local/etc/bash_completion.d |
我们需要按照上面提供的方法,首先在用户更目录下 创建 .nvm 文件
1 |
mkdir ~/.nvm |
然后把 nvm-exec 文件拷贝到你刚才新建的 .nvm 目录下
1 |
cp $(brew --prefix nvm)/nvm-exec ~/.nvm/ |
然后去编辑你的 bash 配置文件 $HOME/.bashrc ,如果你 使用 zsh 那么编辑 $HOME/.zshrc 配置文件
1 |
nano ~/.bashrc |
或
1 |
nano ~/.zshrc |