NODE.JS (1) into the pit

Node.js entered the pit a bit late. Since the nature of the company's business is complex business scenarios, the asynchronous writing method of Node.js is really not suitable for this scenario. Recently, the industry 4.0 that is being studied needs to quickly build a demo, and Node is just capable of doing it well. , so I put my life into the embrace of Node. This is just some sparse knowledge of work. It is not suitable as a learning material for beginners. It is used as a reference.

What is Node.js?

Node.js is a JavaScript runtime environment based on the Chrome V8 engine.
Node.js uses an event-driven, non-blocking I/O model, making it lightweight and efficient.
npm, the package manager for Node.js, is the world's largest ecosystem of open source libraries.


How to install Node.js?

The msi installation package can be downloaded directly under Windows.

Linux can download the compiled version, you can download the source code to compile and install it yourself, or you can search for the rpm package installation in rpmfinder. Personally, it is recommended to use rpm to install it. This solution is the most trouble-free. Compile and install the source code yourself.

Since the koa2 framework (I will explain the reasons for choosing koa later) requires node to require a version above V8.0, rpm find does not have the latest version. Editing and installing by myself is too laborious. After a messy search, I found the magical stuff of NVM.

What is NVM?

nvm is a tool that allows you to install and switch between different versions of node on the same machine (so magical)

How to download, you can refer to https://www.jianshu.com/p/8671e439a811,

It is recommended to look at the official website description: https://github.com/creationix/nvm/blob/master/README.md

Download first: wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.9/install.sh | bash

To see which LTS versions you can install: nvm ls-remote --lts

Install v8.11.1: nvm install v8.11.1

nvm will use the latest installed version as the default version

View the default version of node: nvm current

Set default version: nvm use v8.11.1

Check the locally installed version: nvm ls

Remove installed version: nvm uninstall 6.10.1

It is easy to install, switch versions, and uninstall through nvm.

In the terminal, enter node -v to output the version number of node, indicating that node has been installed normally.







Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324481103&siteId=291194637