Total Pageviews

Friday 24 January 2014

Node Version Manager-nvm

Installation

First you'll need to make sure your system has a c++ compiler. For OSX, XCode will work, for Ubuntu, the build-essential and libssl-dev packages work.

Install script

To install you could use the install script (requires Git) using cURL:
curl https://raw.github.com/creationix/nvm/master/install.sh | sh
or Wget:
wget -qO- https://raw.github.com/creationix/nvm/master/install.sh | sh
The script clones the nvm repository to ~/.nvm and adds the source line to your profile (~/.bash_profile or ~/.profile).

Manual install

For manual install create a folder somewhere in your filesystem with the nvm.sh file inside it. I put mine in a folder called nvm.
Or if you have git installed, then just clone it:
git clone https://github.com/creationix/nvm ~/.nvm
To activate nvm, you need to source it from your shell:
source ~/.nvm/nvm.sh ,这样nvm就安装好了。
I always add this line to my ~/.bashrc, ~/.profile, or ~/.zshrc file or /etc/profile to have it automatically sourced upon login. Often I also put in a line to use a specific version of node.

Usage

To download, compile, and install the latest v0.10.x release of node, do this:
nvm install 0.10
And then in any new shell just use the installed version:
nvm use 0.10
You can create an .nvmrc file containing version number in the project root folder; run the following command to switch versions:
nvm use
Or you can just run it:
nvm run 0.10
If you want to see what versions are installed:
nvm ls
If you want to see what versions are available to install:
nvm ls-remote
To restore your PATH, you can deactivate it.
nvm deactivate
To set a default Node version to be used in any new shell, use the alias 'default':
nvm alias default 0.10 
 
from https://github.com/creationix/nvm 
-----------


root@AR:~/ghost-0.11.1# nvm install 6.6.0
######################################################################## 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v6.6.0 (npm v3.10.3)
root@AR:~/ghost-0.11.1# node -v
v6.6.0
root@AR:~/ghost-0.11.1# nvm use 0.10
Now using node v0.10.47 (npm v2.15.1)
root@AR:~/ghost-0.11.1# node -v
v0.10.47
root@AR:~/ghost-0.11.1#
-----------------------------
nvm安装加速教程以及镜像。 

Node Version Manager

nvm安装加速教程以及镜像。

本仓库镜像站点:https://gitlab.com/mirrorx/nvm

安装/更新

脚本方式安装(简单)

export NVM_SOURCE=https://gitlab.com/mirrorx/nvm.git
curl -o- https://gitlab.com/mirrorx/nvm/-/raw/master/install.sh | bash
export NVM_SOURCE=https://gitlab.com/mirrorx/nvm.git wget -qO- https://gitlab.com/mirrorx/nvm/-/raw/master/install.sh | bash

执行上面任一脚本后,脚本会自动把仓库检出到~/.nvm,然后尝试将下面的配置加入到配置文件(~/.bash_profile, ~/.zshrc, ~/.profile, 或 ~/.bashrc)。

export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # 加载 nvm

检验安装是否成功

执行以下命令:

command -v nvm

如果结果显示nvm则表示已经安装成功.

Git方式安装

如果已经安装git(v1.7.10+):

  1. 克隆仓库到你的用户目录下
  • cd ~/ 然后执行 git clone https://gitlab.com/mirrorx/nvm.git .nvm
  1. cd ~/.nvm进入目录后切换到 git checkout v0.38.0
  2. 执行. ./nvm.sh激活nvm

最后把下面内容加入到~/.bashrc, ~/.profile, 或 ~/.zshrc文件:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # 加载 nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # 加载 nvm bash_completion

手动安装

export NVM_DIR="$HOME/.nvm" && (
  git clone https://gitlab.com/mirrorx/nvm.git "$NVM_DIR"
  cd "$NVM_DIR"
  git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)`
) && \. "$NVM_DIR/nvm.sh"

然后添加下面内容到~/.bashrc, ~/.profile, 或 ~/.zshrc

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # 加载 nvm

手动升级

如果已经安装git(v1.7.10+):

(
  cd "$NVM_DIR"
  git fetch --tags origin
  git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)`
) && \. "$NVM_DIR/nvm.sh"

一些操作

设置默认node

nvm alias default node

设置node安装镜像

export NVM_NODEJS_ORG_MIRROR=https://npmmirror.com/mirrors/node
nvm install node

NVM_NODEJS_ORG_MIRROR=https://npmmirror.com/mirrors/node nvm install 4.2
from https://github.com/ineo6/nvm
---------------------------------------

Awesome Mirror Awesome

nvm

安装nvm

export NVM_SOURCE=https://gitlab.com/mirrorx/nvm.git
curl -o- https://gitlab.com/mirrorx/nvm/-/raw/master/install.sh | bash

设置node镜像:

临时使用:

export NVM_NODEJS_ORG_MIRROR="https://npmmirror.com/mirrors/node"

更多内容请查看:https://github.com/ineo6/nvm

Homebrew

安装脚本:

/bin/bash -c "$(curl -fsSL https://gitee.com/ineo6/homebrew-install/raw/master/install.sh)"

如果你已经安装好brew,只是想更换镜像,也可以访问下面的站点获取设置脚本。

详细介绍&&帮助,请访问:

pypi

临时使用:

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple some-package

长期使用:

升级 pip 到最新的版本 (>=10.0.0) 后进行配置:

pip install pip -U
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

如果您到 pip 默认源的网络连接较差,临时使用本镜像站来升级 pip:

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pip -U

可用源地址

Ruby Gems

gem

# 添加 TUNA 源并移除默认源
gem sources --add https://mirrors.tuna.tsinghua.edu.cn/rubygems/ --remove https://rubygems.org/
# 列出已有源
gem sources -l
# 应该只有一个

Gemfile 和 Bundler 的项目

bundle config mirror.https://rubygems.org https://mirrors.tuna.tsinghua.edu.cn/rubygems/

可用源地址

CocoaPods

旧版使用方式:

pod repo remove master
pod repo add master https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git
pod repo update

新版的CocoaPods不允许用pod repo add直接添加master库了,但是依然可以通过下面方式:

cd ~/.cocoapods/repos 
pod repo remove master
git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git master

最后在Podfile第一行加上:

source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'

可用源地址

Flutter

Flutter是一款跨平台的移动应用开发框架,由Google开源。用Flutter开发的应用可以直接编译成ARM代码运行在AndroidiOS系统上。

Flutter安装时需要从Google Storage 下载文件,如您的网络访问Google受阻,需要使用镜像。

临时使用:

export FLUTTER_STORAGE_BASE_URL="https://mirrors.tuna.tsinghua.edu.cn/flutter"

长期使用:

echo 'export FLUTTER_STORAGE_BASE_URL="https://mirrors.tuna.tsinghua.edu.cn/flutter"' >> ~/.bashrc

此外Flutter开发中还需要用到Dart语言的包管理器Pub,其镜像使用方法参见Pub 镜像安装帮助。

Pub

PubDart官方的包管理器。跨平台的前端应开发框架Flutter也基于Dart,并且可以使用大部分Pub中的库。

临时使用:

PUB_HOSTED_URL="https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" pub get # pub
PUB_HOSTED_URL="https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" flutter packages get # flutter

长期使用:

echo 'export PUB_HOSTED_URL="https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"' >> ~/.bashrc
 from https://github.com/ineo6/awesome-mirror