@echo off
node build.js
node r.js -o build_main.json
@pause
在公交R上刷微博Q还是有很多同学在咨?
于是我觉得应该写一文章解{所有这些v步问题,让新同学也能顺利利入门?/p>
如果你想长期?node 开? 或者想快速更?node 版本, 或者想快速切?node 版本, 那么?strong>?Windows(?osx, linux) 环境? 请?nvm 来安装你?node 开发环? 保持pȝ的干净.
如果你?Windows 做开? 那么你可以?nvmw 来替?nvm
如果你是 windows 环境开? 误q这? 直接查看下一?
直接?github clone nvm 到本? q里假设大家都?~/git
目录存放 git 目:
$ cd ~/git $ git clone https://github.com/cnpm/nvm.git
配置l端启动时自动执?source ~/git/nvm/nvm.sh
, ?~/.bashrc
, ~/.bash_profile
, ~/.profile
, 或?~/.zshrc
文gd以下命o(h):
source ~/git/nvm/nvm.sh
重新打开你的l端, 输入 nvm
$ nvm Node Version Manager Usage: nvm help Show this message nvm --version Print out the latest released version of nvm nvm install [-s] <version> Download and install a <version>, [-s] from source 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 current Display currently activated version 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 version Example: nvm install v0.10.24 Install a specific version number nvm use 0.10 Use the latest available 0.10.x release nvm run 0.10.24 myApp.js Run myApp.js using node v0.10.24 nvm alias default 0.10.24 Set default node version on a shell Note: to remove, delete or uninstall nvm - just remove ~/.nvm, ~/.npm and ~/.bower folders
$ nvm install 0.12.0
于是你就?x)看CD非常快速进度条:
######################################################################## 100.0% Now using node v0.12.0
q可以直接安?iojs 各个版本
$ nvm install iojs
你可以l非常方便地安装各个版本?node ? 你可以查看一下你当前已经安装的版?
$ nvm ls-remote nvm v0.8.26 v0.10.26 v0.11.16 -> v0.12.0
直接?github clone nvmw 到本? q里假设大家都?d:\git
目录存放 git 目:
$ d: $ cd git $ git clone https://github.com/cnpm/nvmw.git
讄 d:\git\nvmw
目录C?PATH
环境变量?
set "PATH=d:\git\nvmw;%PATH%"
重新打开你的l端, 输入 nvmw
$ nvmw Usage: nvmw help Show this message nvmw install [version] Download and install a [version] nvmw uninstall [version] Uninstall a [version] nvmw use [version] Modify PATH to use [version] nvmw ls List installed versions Example: nvmw install v0.6.0 Install a specific version number nvmw use v0.6.0 Use the specific version
$ nvmw install 0.12.0
于是你就?x)看CD非常快速进度条:
######################################################################## 100.0% Now using node v0.12.0
安装 iojs
$ nvmw install iojs-1.4.2
然后你可以l非常方便地安装各个版本?node ? 你可以查看一下你当前已经安装的版?
$ nvmw ls v0.10.26 v0.11.12 Current: v0.11.12
到此, 无论?windows 环境, q是 osx, linux 环境, 都能快速安装多个版本的 node ?
同理 nvm , npm 默认是从国外的源获取和下载包信息, 不慢才奇? 可以通过单的 ---registry
参数, 使用国内的镜?http://registry.npm.taobao.org :
$ npm install koa --registry=http://registry.npm.taobao.org
于是屏幕又哗啦哗啦地一大片输出:
$ npm install koa --registry=http://registry.npm.taobao.org ... koa@0.5.2 node_modules/koa ├── koa-compose@2.2.0 ├── statuses@1.0.2 ├── finished@1.1.1 ├── escape-html@1.0.1 ├── only@0.0.2 ├── debug@0.8.0 ├── fresh@0.2.2 ├── type-is@1.0.1 ├── delegates@0.0.3 ├── mime@1.2.11 ├── co@3.0.5 ├── accepts@1.0.1 (negotiator@0.4.2) └── cookies@0.4.0 (keygrip@1.0.0)
但是毕竟镜像跟官方的 npm 源还是会(x)有一个同步时间差? 目前 cnpm 的默认同步时间间隔是 10 分钟. 如果你是模块发布? 或者你想马上同步一个模? 那么推荐你安?cnpm cli:
$ npm install cnpm -g --registry=http://registry.npm.taobao.org
通过 cnpm 命o(h)? 你可以快速同步Q意模?
$ cnpm sync koa connect mocha
? 我就是不惛_?cnpm cli 怎么? 哈哈, 早就惛_你会(x)q么懒了, 于是我们q有一?web 面:
例如我想马上同步 koa, 直接打开览? http://npm.taobao.org/sync/koa
或者你是命令行? 通过 open 命o(h)打开:
$ open http://npm.taobao.org/sync/koa
如果你安装的模块依赖?C++ 模块, 需要编? 肯定?x)通过 node-gyp 来编? node-gyp 在第一ơ编译的时? 需要依?node 源代? 于是又会(x)?node dist 下蝲, 于是大家又会(x)吐槽, 怎么 npm 安装q么?..
好吧, 于是又要提到 --disturl
参数, 通过中国镜像来下?
$ npm install microtime \ --registry=http://registry.npm.taobao.org \ --disturl=http://npm.taobao.org/mirrors/node
再次要提?cnpm cli, 它已l默认将 --registry
?--disturl
都配|好? 谁用谁知?. 写到q里, 更快疑惑那些不惛_?cnpm cli 又吐?npm 慢的同学是基于什么考虑不在本地安装一?cnpm ?
好了, 看到q里大家应该?node ?npm 已经没有速度慢的问题?
github ? 或者说是它的资?host 被堵而已, 大家可以通过单的 hosts 映射解决:
185.31.16.184 github.global.ssl.fastly.net
听说?APCN2 又断? http://weibo.com/1415338244/ACTYkq8xK
希望文本对你有用. :)