Intro
Node.js is an open source server environment.
Node.js allows you to run JavaScript on the server.
Node.js runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.)
Node.js uses JavaScript on the server
What Can Node.js Do?
Node.js can generate dynamic page content
Node.js can create, open, read, write, delete, and close files on the server
Node.js can collect form data
Node.js can add, delete, modify data in your database
Node.js VS other
Node.js backend framework
●Nest.js- 这种高级Node.js框架可用于构建高效、且可扩展的后端软件。Nest.js可以通过广泛的软件库,来实现TypeScript、MVP、OOP、FP和FRP,因此它比较适合那些企业级的项目。
●Express.j - 凭借着快速、简约的设计,以及强大的HTTP helpers集合等功能,它在Node.js的框架集中名列前茅。Express.js非常适合构建Web、移动应用、以及API。
●Socket.io - 由于带有易用的API,专注于双向实时流,并支持自动化重新连接、多路复用、以及二进制等方面,因此它可以被轻松地使用在不同的设备上。
●Meteor.js - 由于包含了牢固的前端框架,并提供了动态导入、实时功能、前端与后端集成、以及免受隐藏API的影响,它能够让Node.js来创建高质量的软件。
●Koa.js - Koa.js不但有更快的异步功能,而且能够简化错误地处理过程,并提高应用程序的性能。
●Loopback.io - 由于它提供了简化各项工作过程的功能,开发人员可以在几分钟之内开发出各种API。它不但支持按需查询与存储服务,而且能够与各种REST服务、以及许多常见的数据库相兼容。
●Feathers.i - 作为基于Express.js的Node.js框架,它能够与许多前端框架相兼容,并支持各种可选的插件。用户可以用它来轻松地编写出各种实时的Web应用和REST API。
Advantages of Node.js
●Node.js是无阻塞的,可以执行多项任务,并提供异步功能。
●由于进程是在某个线程中,而不是在队列中处理,因此它提高了服务器的活动性。
●Node.js采用的是JavaScript最快的V8 Chrome引擎。
●Node.js让应用程序更具有可扩展性。
node.js作用域问题
node.js没有全局作用域,只有模块作用域(一个模块内的变量/方法只在本模块子下起作用)
模块之间资源共享,使用exports对象将需要在外部被访问的数据变量,方法等导出即可。
Node.js Modules
Built-in Modules
Node.js has a set of built-in modules which you can use without any further installation.
Look at our Built-in Modules Reference for a complete list of modules.
Create Your Own Modules
Use the exports
keyword to make properties and methods available outside the module file.
Save the code above in a file called "myfirstmodule.js"
Node.js File System Module
Common use for the File System module:
- Read files
- Create files
- Update files
- Delete files
- Rename files
Node.js NPM
NPM is a package manager for Node.js packages
后端开发英文语料
https://dzone.com/articles/nodejs-backend-development-features-benefits-price-2