什么是nodejs,方便程序员使用javascript来调用操作系统及相关硬件的代码库。
什么是nvm,nvm是nodejs的版本管理插件。
什么是npm,npm是管理nodejs的三方框架的插件。
1、去git上搜索nvm-windows。下载nvm最新版本(需要翻墙),然后解压安装。
检查是否安装成功。输入nvm回车,会出现helper文档。nvm list 会显示当前已安装的nvm版本。
安装好记得配置环境变量
2、找nvm安装目录,找到settings文件,在最后面加上
node_mirror: https://npm.taobao.org/mirrors/node/
npm_mirror: https://npm.taobao.org/mirrors/npm/
设置淘宝镜像,这样下载会更快。
3、运行cmd,输入nvm install 6.9.2 会安装好npm和node
如何检查是否安装成功,输入nvm use 6.9.2。
然后再输入 node -v 会显示当前nodejs的版本。
在输入 npm -v 会显示当前npm版本。
4、安装npm插件,切换nvm成功之后,输入 npm install supervisor -g。(g是global简写,全局安装)
安装成功后,可以输入 npm list -g --depth=0,只显示最外层的插件。
5、npm设置项目的发布信息。
在项目的文件夹下,输入以下命令:npm init 就会弹出相应的设置关键词
我的电脑:
G:\webProjects>npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.
See `npm help json` for definitive documentation on these fields
and exactly what they do.
Use `npm install <pkg> --save` afterwards to install a package and
save it as a dependency in the package.json file.
Press ^C at any time to quit.
name: (webProjects) myFirstpeoject
Sorry, name can no longer contain capital letters.
name: (webProjects) iii
version: (1.0.0) 1.0.1
description: create,smart
entry point: (index.js)
test command:
git repository:
keywords: http,express
author: shuwen
license: (ISC)
About to write to G:\webProjects\package.json:
{
"name": "iii",
"version": "1.0.1",
"description": "create,smart",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"http",
"express"
],
"author": "shuwen",
"license": "ISC"
}
Is this ok? (yes) yes
6.npm下载插件有时候比较慢,想要提速,当然可以,像nvm一样设置镜像就ok了。npm设置镜像如下操作,设置完成后所有版本的npm都公用该config配置。配置文件在执行目录下。
我的电脑在用户文件夹下。
C:\Users\Administrator\.gitconfig
我的电脑:
C:\Users\Administrator>npm config set registry=https://registry.npm.taobao.org
C:\Users\Administrator>npm config list
; cli configs
user-agent = "npm/3.10.9 node/v6.9.2 win32 x64"
; userconfig C:\Users\Administrator\.npmrc
registry = "https://registry.npm.taobao.org/"
; node bin location = G:\nodejs\node.exe
; cwd = C:\Users\Administrator
; HOME = C:\Users\Administrator
; "npm config ls -l" to show all defaults.
本文详细介绍Node.js环境的搭建步骤,包括nvm的安装与配置、Node.js及npm的版本管理、设置淘宝镜像加速下载,以及如何初始化npm项目。
1490

被折叠的 条评论
为什么被折叠?



