Node.js is a runtime environment that allows you to run JavaScript code outside of a web browser. It uses the V8 JavaScript engine from Google Chrome and provides a set of built-in modules that enable you to build scalable and efficient web applications.

With Node.js, you can create server-side applications and APIs, handle file operations, perform network operations, and much more. It uses an event-driven, non-blocking I/O model, which makes it suitable for building real-time applications, such as chat servers or streaming services.

Node.js also has a package manager called npm (Node Package Manager), which allows you to install and manage third-party libraries and modules for your projects. This vast ecosystem of modules and libraries makes it easy to extend Node.js with additional functionality.

Overall, Node.js has gained popularity among developers due to its performance, scalability, and the ability to write server-side applications using JavaScript – a language that is already familiar to many web developers.

1.Nodejs的安装

NPM是Node提供的模块管理工具,可以非常方便的下载安装很多前端框架,包括Jquery、AngularJS、VueJs都有。为了后面学习方便,我们先安装node及NPM工具.

1.1.安装Nodejs

Nodejs自带npm,安装好Nodejs就安装好了npm

  • NodeJs下载:Node.js — Download Node.js®

  • 安装:双击安装,如果是绿色版,直接解压缩,配置环境变量

  • 升级:npm install npm@latest -g [不升级]

  • 测试Node:cmd -> node -v

  • 测试Npm: cmd -> npm -v

  • 淘宝镜像:npm config set registry https://registry.npm.taobao.org

  • 腾讯镜像:npm config set registry Tencent-NPM [推荐]

1.2.cnpm的使用

淘宝团队做的国内镜像,因为npm的服务器位于国外可能会影响安装。淘宝镜像与官方同步频率目前为 10分钟 一次以保证尽量与官方服务同步。

  • 安装:命令提示符执行 npm install cnpm -g --registry=https://registry.npm.taobao.org

  • 测试cnpm :cnpm -v

    2.Nodejs介绍

    2.1.介绍

    官方解释:

    简单理解:Nodejs是一个JavaScript运行环境,让JavaScript开发服务端代码成为可能

    简单理解:Npm是在Nodejs平台上的js包管理系统,如安装jquery:npm install jquery , 为了方便理解下面有一个对比:

    随后,在node的基础上,涌现出了一大批的前端框架:Angular(MVC->MVVM),Vue(MVVM)等等

    2.2.主流前端框架

    前端框架三巨头:

  • Vue.js:vue.js以轻量易用著称

  • React.js:vue.js和React.js发展速度最快, 集web前端与app于一身技术

  • AngularJS:AngularJS是曾经的老大。

07-26 05:05