Window下安装npm

来源:互联网 发布:微信在线客服系统源码 编辑:程序博客网 时间:2024/04/29 04:43

Node.js停火各大技术论坛都在讨论,前段时间工作太忙没时间学习,趁着周末空闲玩玩,在网上找了些资料发现Node.js本身有windows版和unix版下载和使用都挺方便但是其扩展模块依赖复杂通过手动到网站上下载非常麻烦,所以的NPM介绍都要求在Linux或在windows上通过Cygwin进行安装,按照网上的办法下载Cygwin安装node.js死活不成功(执行./configure 报cygwin not supported)多次尝试无果,网上又无人解答,在精神处在崩溃边境无意中点开了NPM的说明文档,竟然有一节是说明如何在windows下安装NPM,按照其说明执行终于成功在windows 下安装了NPM。用起来还是很爽的就是下载文件慢了点。

第一步: 下载node.js的windows版

当前最新版本是http://nodejs.org/dist/v0.5.10/node.exe


第二步:设置环境变量

把node.exe所在目录加入到PATH环境变量中。
配置成功后可以在CMD中通过node --version 看到node.js对应的版本号
C:\Users\fn>node --version
v0.5.10

第三步: 安装git

直接到以下地址(http://code.google.com/p/msysgit/downloads/list)下载git windows安装文,目前最新版是Git-1.7.7-preview20111014.exe,按照提示一步步安装即可。安装完成后把git安装bin目录加入PATH环境变量

CMD中运行 git --version 确认安装是否成功

C:\Users\fn>git --version
git version 1.7.7.msysgit.1

第四步: 安装 npm

在确保node.exe和git都在PATH环境变量中后执行以下命令:

git config --system http.sslcainfo /bin/curl-ca-bundle.crt
git clone --recursive git://github.com/isaacs/npm.git
cd npm
node cli.js install npm -gf
下面来测试一下是否成功,一切OK开始Node.JS之旅

D:\develop\nodejs\hello>npm install -d
npm info it worked if it ends with ok
npm info using npm@1.0.103
npm info using node@v0.5.10
npm info preinstall application-name@0.0.1
npm info addNamed [ 'jade', '>= 0.0.1' ]
npm info addNamed [ 'express', '2.5.0' ]


最好设置下国内镜像要不然下载会很慢

github npm 撞墙的解决方案。 

github: 
代理服务器是必须的,我用的是本地的astrill 
给curl设置代理 
export http_proxy="127.0.0.1:3213" 
export https_proxy="127.0.0.1:3213" 
ok了 

npm: 
设置国内镜像 npm config set registry http://registry.npmjs.vitecho.com 

0 0
原创粉丝点击