NodeJS(node.exe, npm, express, live-server)安装

时间:2021-08-30 18:22:31

1.下载node.exe

下载https://nodejs.org/en/download/current/

创建D:\GreenSoftware\NodeJS目录,并将node.exe放到目录中。

2.设定环境变量

把D:\GreenSoftware\NodeJS加入path环境变量中。

3.下载npm,

下载https://github.com/npm/npm/releases

将下载的压缩包里面的文件解压放到D:\GreenSoftware\NodeJS\npmjs目录中。

4.安装npm

打开cmd.exe,进入D:\GreenSoftware\NodeJS\npmjs目录,

执行node cli.js install npm -gf命令(其中-gf是指全局安装的意思)

NodeJS(node.exe, npm, express, live-server)安装

5.测试

NodeJS(node.exe, npm, express, live-server)安装

在D:\GreenSoftware\NodeJS目录下新建test.js文件,写入如下内容:

var http = require('http');

http.createServer(function(req, res) {

res.writeHead(200, {

'Content-Type': 'text/plain'

});

res.end('Hello World\n');

}).listen(8899, "127.0.0.1");

console.log('Server running at http://127.0.0.1:1337/');

NodeJS(node.exe, npm, express, live-server)安装

执行node test.js命令

打开浏览器:访问127.0.0.1:8899

NodeJS(node.exe, npm, express, live-server)安装

NodeJS(node.exe, npm, express, live-server)安装

6.安装Express

执行npm install express -gf命令 和 npm install express-generator -gf命令

NodeJS(node.exe, npm, express, live-server)安装

NodeJS(node.exe, npm, express, live-server)安装

NodeJS(node.exe, npm, express, live-server)安装

7.安装Web Server

执行npm install live-server -gf命令

NodeJS(node.exe, npm, express, live-server)安装

8.安装gulp

Gulp is a task launcher that runs under Node.js, allowing us to automate tasks that we do frequently.

Until now the best known manager was Grunt but the simplicity and speed that Gulp offers has made its use spread to many projects.

Gulp相当于Java中的Maven,是一个“工程的构建工具”

执行npm install -gf gulp命令

NodeJS(node.exe, npm, express, live-server)安装

9.安装bower

bower是一个前端JavaScript文件的“依赖管理工具”,构建于git之上。

执行npm install -gf bower命令

NodeJS(node.exe, npm, express, live-server)安装

10.安装node-gyp

gyp是为Chromium项目创建的项目生成工具,可以从平台无关的配置生成平台相关的Visual Studio、Xcode、Makefile的项目文件。

node-gyp在较新的Node版本中都是自带的(平台相关),用来编译原生C++模块。

执行npm install -gf node-gyp命令

11.安装node-sass

node-sass提供了一个nodejs到libsass的桥梁.libsass是广受欢迎的css预处理器sass的c版本

执行

npm install -gf sass

npm install -gf node-sass

npm install node-sass-middleware

命令

12.安装node-less

LESS 是一个编写 CSS 的很好的方式 ,让你可以使用变量,嵌套规则,混入以及其它许多有用的功能,它可以帮助您更好地组织你的 CSS 代码。

执行

npm install -gf less

npm install -gf node-less

命令