Getting to know Node JS

One, NVM

  1. nvmCan switch nodeversion management node, download address https://github.com/coreybutler/nvm-windows/releases, as follows:
  • nvm-noinstall.zip: Green free installation version, but it needs to be configured when using it.
  • nvm-setup.zip: Installed version, recommended
  1. nvm Common commands are as follows:
  • nvm listSee all current nodeversions
  • nvm install v10.13.0 Install the specified version
  • nvm use -delete-prefix 10.13.0 Switch to the specified version

Two, NodeJS and JS

  1. ECMAScript,As follows:
  • It defines the syntax, writing JavaScriptand nodejSmust comply
  • Variable definition, loop, judgment, function
  • Prototype and prototype chain, scope and closure, asynchronous
  • Can not operate DOM, you can not monitor clickevents, you can not send ajaxrequest
  • Can not process httpthe request, the file can not operate
  • Only ECMAScript, can hardly do any actual projects
  1. JavaScript,As follows:
  • Use ECMAScriptsyntax specification, plus web APIindispensable
  • DOMOperation, BOMoperation, event binding, Ajaxetc.
  • Combine the two to complete any operation on the browser side
  1. nodeJS,As follows:
  • Use ECMAScriptsyntax specification, plus nodejS APIindispensable
  • Processing http, processing files, etc., learninghttp://nodejs.cn/api/assert.html
  • Combination of both, to complete the serverend of any operation
  1. The summary is as follows:
  • ECMAScript Is a grammar specification
  • nodeJS = ECMAScript + nodeJS API

Three, server side and front-end development

  1. server The difference between front-end and front-end development is as follows:
  • Service stability
  • Consider memory and CPU(optimization, expansion)
  • Logging
  • Safety
  • Cluster and service split
  1. Service stability is as follows:
  • server The end may be subject to various malicious attacks and misoperations
  • A single client can hang up unexpectedly, but the server cannot
  • PM2 Wait for the process
  1. Consider memory and CPU(optimization, expansion) as follows:
  • The client exclusively a browser, memory, and CPUnot a problem
  • serverThe end has to carry a lot of requests, CPUand memory is a scarce resource
  • streamWrite the log, using redisdepositsession
  1. The log records are as follows:
  • The front end will also participate in writing the log, but it is only the originator of the log and does not care about the follow-up
  • server The end needs to record logs, store logs, and analyze logs. The front end does not care
  • There are multiple logging methods and how to analyze the logs
  1. Security, as follows:
  • server The end must be ready to receive various malicious attacks at any time, while the front end must be much less
  • For example, unauthorized operation, database attacks, etc.
  • Login authentication, prevent XSSattacks and sqlinjection
  1. The cluster and service are split as follows:
  • Product development is fast, traffic may increase rapidly
  • Carry large traffic by expanding machines and service splitting
  • Support service splitting in design

Guess you like

Origin blog.csdn.net/weixin_42614080/article/details/110675774