本文介绍下Mac OS X下安装和卸载Node.js的几种方法:
- 源码手工编译
- 官方pkg安装包
- 第三方软件
- nvm (Node Version Manager 便于多个版本并存、切换)
[一]、源码手工编译
安装:标准的三板斧:
1 2 3 |
./configure make make install |
卸载: make uninstall
[二]、官方pkg安装包
安装: 双击运行,安装提示一步一步执行即可。
卸载:
1 2 3 4 5 6 7 |
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom \ | while read i; do sudo rm /usr/local/${i} done sudo rm -rf /usr/local/lib/node \ /usr/local/lib/node_modules \ /var/db/receipts/org.nodejs.* |
有人已经整理了一份卸载脚本详见:https://raw.github.com/gist/2697848/uninstall-node.sh
[三]、第三方软件
- Homebrew
- MacPorts
这里就不详细介绍了。
[四]、nvm (Node Version Manager)
详见官方介绍:https://github.com/creationix/nvm#node-version-manager
我选择的是手工安装,详细步骤如下:
1 2 3 4 5 6 7 8 9 |
# clone repo $ git clone git://github.com/creationix/nvm.git ~/.nvm # 在 ~/.bashrc 和 ~/.profile 添加如下内容( # [[ -s "/Users/micmiu/.nvm/nvm.sh" ]] && source "/Users/micmiu/.nvm/nvm.sh" # “/Users/micmiu/.nvm” 为nvm 的根目录 # 重新打开终端执行下面的命令 $ nvm install v0.10.17 # 比如 set default node $ nvm alias default 0.10.17 |
nvm 基本命令介绍
Usage:
nvm help Show this message
nvm install [-s] <version> Download and install a <version>
nvm uninstall <version> Uninstall a version
nvm use <version> Modify PATH to use <version>
nvm run <version> [<args>] Run <version> with <args> as arguments
nvm ls List installed versions
nvm ls <version> List versions matching a given description
nvm ls-remote List remote versions available for install
nvm deactivate Undo effects of NVM on current shell
nvm alias [<pattern>] Show all aliases beginning with <pattern>
nvm alias <name> <version> Set an alias named <name> pointing to <version>
nvm unalias <name> Deletes the alias named <name>
nvm copy-packages <version> Install global NPM packages contained in <version> to current versionExample:
nvm install v0.4.12 Install a specific version number
nvm use 0.2 Use the latest available 0.2.x release
nvm run 0.4.12 myApp.js Run myApp.js using node v0.4.12
nvm alias default 0.4 Auto use the latest installed v0.4.x version
本文介绍到此结束@Michael Sun.
原创文章,转载请注明: 转载自micmiu – 软件开发+生活点滴[ http://www.micmiu.com/ ]
本文链接地址: http://www.micmiu.com/lang/nodejs/mac-osx-nodejs-install/
0 条评论。