1、进入nodejs官方网站下载软件(nodejs.org),
2、下载完成后,双击默认安装。安装程序会自动添加环境变量
3、检测nodejs是否安装成功。打开cmd命令行 输入 node - v 显示当前版本号
4、检查npm是否安装。由于新版的NodeJS已经集成了npm,所以之前npm也一并安装好了。同样可以使用cmd命令行中键入 npm -v
5、在一个目录下,例如D:\node\ 下建立几个子目录:
mkdir npm-global //存放node全局模块
mkdir npm-cache //npm缓存路径
6、配置全局模块的安装路径到node-global文件夹,npm缓存到npm-cache文件夹
npm config set prefix "D:\node\node-global"
npm config set cache "D:\node\node-cache"
7、把D:\node\node-global加到系统PATH里面,方面直接运行使用!!
8、验证下吧,装个全局模块:
npm install express -g
查看下node-global和node-cache文件夹下是否有惊喜,嘿嘿~
chh说原来,最新express4.0版本中将命令工具分家出来了(项目地址:https://github.com/expressjs/generator),所以我们还需要安装一个命令工具,命令如下:
npm install -g express-generator
这样后,在命令行就可以直接输入express来验证
8.1 安装bower, npm install bower -g; -g表示全局
输入 node,
require('bower') 显示如下表示 安装成功!
那就不检查了,好像不装在全局,装在项目目录下是可以用的```
###chh 说bower是包管理器,不用require
这样后,在命令行就可以直接输入bower来验证
![验证bower](http://upload-images.jianshu.io/upload_images/2066586-26d39e286842f493.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
#卸载node
Uninstall from Programs & Features with the uninstaller.
Reboot (or you probably can get away with killing all node-related processes from Task Manager).
Look for these folders and remove them (and their contents) if any still exist. Depending on the version you installed, UAC settings, and CPU architecture, these may or may not exist:
```C:\Program Files (x86)\Nodejs```
C:\Program Files\Nodejs
```C:\Users\{User}\AppData\Roaming\npm (or %appdata%\npm)```
```C:\Users\{User}\AppData\Roaming\npm-cache(or %appdata%\npm-cache)```
[Check your %PATH% environment variable](http://stackoverflow.com/questions/141344/how-to-check-if-directory-exists-in-path) to ensure no references to Nodejs or npm exist.
If it's *still* not uninstalled, type where node at the command prompt and you'll see where it resides -- delete that (and probably the parent directory) too.
Reboot, for good measure.